Bugzilla – Attachment 187349 Details for
Bug 6473
Test bug for Git-bz ✔ ❤ ★
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix case when range is HEAD
ff3586c.patch (text/plain), 7.37 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-10-03 02:07:32 UTC
(
hide
)
Description:
Fix case when range is HEAD
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-10-03 02:07:32 UTC
Size:
7.37 KB
patch
obsolete
>From ff3586c269e35563ba9f8febc4e261a510c12609 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Thu, 2 Oct 2025 23:06:40 -0300 >Subject: [PATCH] Fix case when range is HEAD >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >--- > lib/GitBz/Commands.pm | 2 ++ > lib/GitBz/Commands/Attach.pm | 55 ++++++++++++++++++------------------ > lib/GitBz/Config.pm | 2 ++ > lib/GitBz/Git.pm | 15 +++++++--- > 4 files changed, 42 insertions(+), 32 deletions(-) > >diff --git a/lib/GitBz/Commands.pm b/lib/GitBz/Commands.pm >index 154978f..f39a5e8 100644 >--- a/lib/GitBz/Commands.pm >+++ b/lib/GitBz/Commands.pm >@@ -16,7 +16,9 @@ package GitBz::Commands; > # along with git-bz; if not, see <https://www.gnu.org/licenses>. > > use Modern::Perl; >+ > use Try::Tiny qw(catch try); >+ > use GitBz::Exception; > use GitBz::Config; > use GitBz::RestClient; >diff --git a/lib/GitBz/Commands/Attach.pm b/lib/GitBz/Commands/Attach.pm >index fdac4f3..60f7d2f 100644 >--- a/lib/GitBz/Commands/Attach.pm >+++ b/lib/GitBz/Commands/Attach.pm >@@ -22,6 +22,7 @@ use utf8; > use Getopt::Long qw(GetOptionsFromArray); > use Try::Tiny qw(catch try); > use File::Temp; >+ > use GitBz::Git; > use GitBz::Exception; > use GitBz::StatusWorkflow; >@@ -90,17 +91,17 @@ sub attach_patches { > my ( $self, $bug_ref, $commits, $opts ) = @_; > > my $client = $self->{commands}->{client}; >- my $bug = $client->get_bug($bug_ref); >- >+ my $bug = $client->get_bug($bug_ref); >+ > my $is_first = 1; > for my $commit (@$commits) { >- my $patch = GitBz::Git->format_patch( $commit->{id} . '^..' . $commit->{id} ); >- my $filename = sprintf( "%s.patch", substr( $commit->{id}, 0, 7 ) ); >+ my $patch = GitBz::Git->format_patch( $commit->{id} . '^..' . $commit->{id} ); >+ my $filename = sprintf( "%s.patch", substr( $commit->{id}, 0, 7 ) ); > my $description = $commit->{subject}; >- my $body = GitBz::Git->run( 'log', '--format=%b', '-1', $commit->{id} ); >- my $comment = $body || "Patch from commit " . substr( $commit->{id}, 0, 7 ); >+ my $body = GitBz::Git->run( 'log', '--format=%b', '-1', $commit->{id} ); >+ my $comment = $body || "Patch from commit " . substr( $commit->{id}, 0, 7 ); > my @obsoletes; >- >+ > if ( $opts->{edit} && $is_first ) { > ( $description, $comment, my $obsoletes_ref ) = $self->edit_attachment_comment( $bug, $commit ); > @obsoletes = @$obsoletes_ref if $obsoletes_ref; >@@ -111,7 +112,7 @@ sub attach_patches { > $patch, > $filename, > $description, >- comment => $comment, >+ comment => $comment, > obsoletes => \@obsoletes > ); > >@@ -126,11 +127,11 @@ sub edit_attachment_comment { > my $template = ""; > $template .= "# Attachment to Bug $bug->{id} - $bug->{summary}\n\n"; > $template .= $commit->{subject} . "\n\n"; >- >+ > # Add commit body as initial comment > my $body = GitBz::Git->run( 'log', '--format=%b', '-1', $commit->{id} ); > $template .= $body . "\n\n" if $body; >- >+ > # Show existing patches for obsoleting > if ( $bug->{attachments} && @{ $bug->{attachments} } ) { > for my $patch ( @{ $bug->{attachments} } ) { >@@ -140,17 +141,17 @@ sub edit_attachment_comment { > } > $template .= "\n"; > } >- >+ > # Add status options >- my $client = $self->{commands}->{client}; >+ my $client = $self->{commands}->{client}; > my $workflow = GitBz::StatusWorkflow->new($client); > $template .= "# Current status: $bug->{status}\n"; >- my $status_values = $workflow->get_next_status_values($bug->{status}); >+ my $status_values = $workflow->get_next_status_values( $bug->{status} ); > for my $status (@$status_values) { > $template .= "# Status: $status\n"; > } > $template .= "\n"; >- >+ > # Add patch complexity options > my $complexity = $bug->{cf_patch_complexity} || ""; > $template .= "# Current patch-complexity: $complexity\n"; >@@ -161,19 +162,19 @@ sub edit_attachment_comment { > } > } > $template .= "\n"; >- >+ > # Add depends options >- my $depends = $bug->{depends_on} || []; >- my $depends_str = ref($depends) eq 'ARRAY' ? join(' ', @$depends) : $depends; >+ my $depends = $bug->{depends_on} || []; >+ my $depends_str = ref($depends) eq 'ARRAY' ? join( ' ', @$depends ) : $depends; > $template .= "# Current depends: $depends_str\n"; > $template .= "# Depends: bug xxxx\n"; > $template .= "# Depends: bug yyyy\n"; > $template .= "\n"; >- >+ > $template .= "# Please edit the description (first line) and comment (other lines).\n"; > $template .= "# Lines starting with '#' will be ignored. Delete everything to abort.\n"; > $template .= "# To obsolete existing patches, uncomment the appropriate lines.\n"; >- >+ > my $edited = $self->edit_template($template); > return $self->parse_edited_content($edited); > } >@@ -198,18 +199,16 @@ sub edit_template { > > sub parse_edited_content { > my ( $self, $content ) = @_; >- >+ > my @lines = split /\n/, $content; >- my @non_comment_lines = grep { !/^#/ && /\S/ } @lines; # Also filter empty lines >- >+ my @non_comment_lines = grep { !/^#/ && /\S/ } @lines; # Also filter empty lines >+ > my $description = shift @non_comment_lines || ""; > $description =~ s/^\s+|\s+$//g; >- > >- > my @obsoletes; > my @comment_lines; >- >+ > for my $line (@non_comment_lines) { > if ( $line =~ /^\s*Obsoletes\s*:\s*(\d+)/ ) { > push @obsoletes, $1; >@@ -217,12 +216,12 @@ sub parse_edited_content { > push @comment_lines, $line; > } > } >- >+ > my $comment = join( "\n", @comment_lines ); > $comment =~ s/^\s+|\s+$//g; >- >+ > GitBz::Exception->throw("Empty description, aborting\n") unless $description; >- >+ > return ( $description, $comment, \@obsoletes ); > } > >diff --git a/lib/GitBz/Config.pm b/lib/GitBz/Config.pm >index d3f9edc..7acc3d5 100644 >--- a/lib/GitBz/Config.pm >+++ b/lib/GitBz/Config.pm >@@ -16,8 +16,10 @@ package GitBz::Config; > # along with git-bz; if not, see <https://www.gnu.org/licenses>. > > use Modern::Perl; >+ > use Config::Tiny; > use File::HomeDir; >+ > use GitBz::Git; > > my $DEFAULT_CONFIG = { >diff --git a/lib/GitBz/Git.pm b/lib/GitBz/Git.pm >index 490cb7d..ce86e52 100644 >--- a/lib/GitBz/Git.pm >+++ b/lib/GitBz/Git.pm >@@ -40,7 +40,12 @@ sub run { > > sub rev_list { > my ( $class, @args ) = @_; >- my $output = $class->run( 'rev-list', '--pretty=format:%s', @args ); >+ >+ unshift( @args, '--pretty=format:%s' ); >+ unshift( @args, '--max-count=1' ) >+ if $args[1] eq 'HEAD'; >+ >+ my $output = $class->run( 'rev-list', @args ); > > my @commits; > my @lines = split /\n/, $output; >@@ -64,16 +69,18 @@ sub get_commits { > my ( $class, $range ) = @_; > > # Try as single commit first - exactly like original git-bz >- my $rev = try { >+ my $rev = try { > $class->run( 'rev-parse', $range, '--verify' ); >- } catch { >- undef >+ } catch { >+ undef > }; > > if ($rev) { >+ > # Single commit - return just that one commit > return $class->rev_list( '--max-count=1', $rev ); > } else { >+ > # Not a single commit, treat as range > return $class->rev_list($range); > } >-- >2.51.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6473
:
4386
|
6837
|
6838
|
6839
|
6840
|
6841
|
6842
|
6843
|
7154
|
7155
|
7567
|
7994
|
7995
|
7996
|
7997
|
8018
|
9807
|
9808
|
9813
|
9831
|
9832
|
9836
|
9854
|
10842
|
10843
|
10844
|
10845
|
10846
|
10847
|
10848
|
10849
|
10850
|
10851
|
10852
|
10853
|
10854
|
10855
|
10856
|
10857
|
10858
|
11540
|
11543
|
11544
|
12502
|
12513
|
12514
|
12515
|
12516
|
12517
|
12518
|
12519
|
13473
|
13673
|
14955
|
14969
|
14970
|
14972
|
15201
|
18949
|
18950
|
18951
|
18952
|
18953
|
18954
|
18955
|
18956
|
18957
|
18958
|
18959
|
18960
|
18961
|
18962
|
18963
|
18971
|
18972
|
19518
|
19519
|
19591
|
19592
|
19871
|
19879
|
19880
|
19881
|
19882
|
20011
|
20012
|
20013
|
20014
|
22477
|
22481
|
22482
|
22496
|
22502
|
22503
|
31958
|
32444
|
32445
|
32446
|
32447
|
32448
|
32449
|
32450
|
32451
|
32452
|
34200
|
34201
|
34625
|
34999
|
35130
|
35269
|
35273
|
35274
|
35275
|
35276
|
35277
|
35279
|
35280
|
35303
|
40954
|
40957
|
45345
|
45349
|
45731
|
45732
|
45733
|
45734
|
47283
|
47284
|
47298
|
47299
|
47300
|
47334
|
47336
|
49083
|
56974
|
61059
|
61069
|
62038
|
65313
|
77301
|
78016
|
79959
|
80178
|
80179
|
80180
|
80181
|
80182
|
84400
|
86644
|
86645
|
87152
|
88128
|
95586
|
95716
|
97394
|
99026
|
99027
|
114217
|
114218
|
114219
|
114220
|
114221
|
114222
|
114223
|
114224
|
114225
|
114226
|
119255
|
121181
|
131891
|
131893
|
131894
|
134862
|
144109
|
144144
|
144671
|
144672
|
144673
|
147183
|
149030
|
149031
|
149032
|
149033
|
160566
|
160567
|
160568
|
182093
|
183107
|
183177
|
183178
|
183179
|
183180
|
183182
|
183183
|
183285
|
183286
|
187209
|
187321
|
187322
|
187323
|
187324
|
187325
|
187326
|
187327
|
187328
|
187329
|
187330
|
187331
|
187332
|
187333
|
187334
|
187335
|
187336
|
187337
|
187338
|
187339
|
187340
|
187341
|
187342
|
187343
|
187344
|
187345
|
187346
|
187347
|
187348
|
187349
|
187350
|
187351
|
187352
|
187353
|
187354
|
187355
|
187356
|
187357
|
187358
|
187359
|
187360
|
187361
|
187362
|
187363
|
187364
|
187365
|
187366
|
187367
|
187368
|
187369
|
187370
|
187371
|
187372
|
187545
|
187546