Bugzilla – Attachment 178012 Details for
Bug 39114
Auto-rebase script does not deal correctly with deleted files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39114: The auto-rebase script - Fix files removal
Bug-39114-The-auto-rebase-script---Fix-files-remov.patch (text/plain), 3.31 KB, created by
Nick Clemens (kidclamp)
on 2025-02-13 14:15:28 UTC
(
hide
)
Description:
Bug 39114: The auto-rebase script - Fix files removal
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-02-13 14:15:28 UTC
Size:
3.31 KB
patch
obsolete
>From 831c4b3c73e1dbd88e5038235040b89724f0c727 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 12 Feb 2025 19:11:14 +0000 >Subject: [PATCH] Bug 39114: The auto-rebase script - Fix files removal > >Wrong handling of the return of the try-catch, $git->rm has an output >("rm /file/path"). > >This patch retrieves the status from the `git diff-tree` output > >Test plan: >git checkout HEAD~100 (so you are before 38664) >git rm mainpage.pl >edit C4/Auth.pm and make some changes >git commit -a --no-verify -m"Bug 12345: test" >then rebase your branch >Retrieve the auto_rebase.pl version from this patch and run it >perl auto_rebase.pl > >The resulted commit should not contain mainpage.pl > >WNC amended patch, tidied, ironically > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > misc/devel/auto_rebase.pl | 37 ++++++++++++++++++++++--------------- > 1 file changed, 22 insertions(+), 15 deletions(-) > >diff --git a/misc/devel/auto_rebase.pl b/misc/devel/auto_rebase.pl >index 3dd01c4d253..f0dffaab01b 100755 >--- a/misc/devel/auto_rebase.pl >+++ b/misc/devel/auto_rebase.pl >@@ -147,24 +147,31 @@ while ( my ( $i, $commit ) = each @commits ) { > say BLUE sprintf "\tProcessing commit %s... (%s/%s)", $commit, $i + 1, scalar @commits; > > # Get the list of modified files in this commit >- my @modified_files = $git->diff_tree( '--no-commit-id', '--name-only', '-r', $commit ); >-FILE: while ( my ( $ii, $file ) = each @modified_files ) { >+ my @modified_files = $git->diff_tree( '--no-commit-id', '--name-status', '-r', $commit ); >+ while ( my ( $ii, $file_status ) = each @modified_files ) { >+ $file_status =~ s/ +/ /; >+ my ( $status, $file ) = split ' ', $file_status; >+ > say BLUE sprintf "\t\tProcessing file %s... (%s/%s)", $file, $ii + 1, scalar @modified_files; > > # Retrieve the content of the file from this commit >- my @content = try { >- $git->RUN( "show", "$commit:$file" ); >- } catch { >- if ( $_->error =~ m{fatal: path '.*' exists on disk, but not in '$commit'} ) { >- say BLUE "\t\t\tFile does not exist, removing..."; >+ if ( $status eq 'D' ) { >+ try { > $git->rm($file); >- } else { >- say RED "Something wrong happened when retrieving the file from the branch."; >+ } catch { >+ say RED "Something wrong happened when removing the file from the branch."; > exit 2; >- } >- }; >+ }; >+ next; >+ } > >- next unless @content; # We removed the file >+ my @content; >+ try { >+ @content = $git->RUN( "show", "$commit:$file" ); >+ } catch { >+ say RED "Something wrong happened when retrieving the file from the branch."; >+ exit 2; >+ }; > > my $parent_directory = dirname($file); > unless ( -f $parent_directory ) { >@@ -180,10 +187,10 @@ FILE: while ( my ( $ii, $file ) = each @modified_files ) { > say RED "Cannot tidy $file: $_"; > exit 2; > }; >- } > >- # Stage the changes >- $git->add($_) for @modified_files; >+ # Stage the changes >+ $git->add($file); >+ } > > # Get the original commit information > my ( $author, $date, $message ) = get_commit_info($commit); >-- >2.39.5
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 39114
:
177970
|
177986
|
177988
|
177989
|
178012
|
178035