Lines 147-170
while ( my ( $i, $commit ) = each @commits ) {
Link Here
|
147 |
say BLUE sprintf "\tProcessing commit %s... (%s/%s)", $commit, $i + 1, scalar @commits; |
147 |
say BLUE sprintf "\tProcessing commit %s... (%s/%s)", $commit, $i + 1, scalar @commits; |
148 |
|
148 |
|
149 |
# Get the list of modified files in this commit |
149 |
# Get the list of modified files in this commit |
150 |
my @modified_files = $git->diff_tree( '--no-commit-id', '--name-only', '-r', $commit ); |
150 |
my @modified_files = $git->diff_tree( '--no-commit-id', '--name-status', '-r', $commit ); |
151 |
FILE: while ( my ( $ii, $file ) = each @modified_files ) { |
151 |
while ( my ( $ii, $file_status ) = each @modified_files ) { |
|
|
152 |
$file_status =~ s/ +/ /; |
153 |
my ( $status, $file ) = split ' ', $file_status; |
154 |
|
152 |
say BLUE sprintf "\t\tProcessing file %s... (%s/%s)", $file, $ii + 1, scalar @modified_files; |
155 |
say BLUE sprintf "\t\tProcessing file %s... (%s/%s)", $file, $ii + 1, scalar @modified_files; |
153 |
|
156 |
|
154 |
# Retrieve the content of the file from this commit |
157 |
# Retrieve the content of the file from this commit |
155 |
my @content = try { |
158 |
if ( $status eq 'D' ) { |
156 |
$git->RUN( "show", "$commit:$file" ); |
159 |
try { |
157 |
} catch { |
|
|
158 |
if ( $_->error =~ m{fatal: path '.*' exists on disk, but not in '$commit'} ) { |
159 |
say BLUE "\t\t\tFile does not exist, removing..."; |
160 |
$git->rm($file); |
160 |
$git->rm($file); |
161 |
} else { |
161 |
} catch { |
162 |
say RED "Something wrong happened when retrieving the file from the branch."; |
162 |
say RED "Something wrong happened when removing the file from the branch."; |
163 |
exit 2; |
163 |
exit 2; |
164 |
} |
164 |
}; |
165 |
}; |
165 |
next; |
|
|
166 |
} |
166 |
|
167 |
|
167 |
next unless @content; # We removed the file |
168 |
my @content; |
|
|
169 |
try { |
170 |
@content = $git->RUN( "show", "$commit:$file" ); |
171 |
} catch { |
172 |
say RED "Something wrong happened when retrieving the file from the branch."; |
173 |
exit 2; |
174 |
}; |
168 |
|
175 |
|
169 |
my $parent_directory = dirname($file); |
176 |
my $parent_directory = dirname($file); |
170 |
unless ( -f $parent_directory ) { |
177 |
unless ( -f $parent_directory ) { |
Lines 180-189
FILE: while ( my ( $ii, $file ) = each @modified_files ) {
Link Here
|
180 |
say RED "Cannot tidy $file: $_"; |
187 |
say RED "Cannot tidy $file: $_"; |
181 |
exit 2; |
188 |
exit 2; |
182 |
}; |
189 |
}; |
183 |
} |
|
|
184 |
|
190 |
|
185 |
# Stage the changes |
191 |
# Stage the changes |
186 |
$git->add($_) for @modified_files; |
192 |
$git->add($file); |
|
|
193 |
} |
187 |
|
194 |
|
188 |
# Get the original commit information |
195 |
# Get the original commit information |
189 |
my ( $author, $date, $message ) = get_commit_info($commit); |
196 |
my ( $author, $date, $message ) = get_commit_info($commit); |
190 |
- |
|
|