aboutsummaryrefslogtreecommitdiffstats
path: root/smart_change.pl
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2019-04-04 01:28:17 +0200
committerGuillem Jover <guillem@debian.org>2019-04-04 14:32:42 +0200
commit97729276414fca15d305e1ab62ff346eb13dcd4e (patch)
tree71f9e3a6f5df521de527598d752205b9130fb6b6 /smart_change.pl
parent69ba1b173fccf08a6411f7ec06066103bfeb6d07 (diff)
smart-change: Add new --modified and --commit options
This should help work off the VCS. The --modified option helps with the following workflow: 1) Modify english version; commit. 2) Modify translations; use smart_change with -m; commit. The --commit option helps with the following workflow: 1) Modify english version; commit. 2) Modify translations; commit. 3) Use smart_change with -c from 2); commit.
Diffstat (limited to 'smart_change.pl')
-rwxr-xr-xsmart_change.pl33
1 files changed, 30 insertions, 3 deletions
diff --git a/smart_change.pl b/smart_change.pl
index 0814ac118d6..9f62ebbb5eb 100755
--- a/smart_change.pl
+++ b/smart_change.pl
@@ -16,15 +16,17 @@ use Local::VCS;
use Webwml::TransCheck;
use Webwml::Langs;
-our ($opt_h, $opt_v, $opt_n, @opt_l, @opt_s);
+our ($opt_h, $opt_v, $opt_n, @opt_l, @opt_s, $opt_m, $opt_c);
sub usage {
print <<'EOT';
-Usage: smart_change.pl [options] origfile [origfile ...]
+Usage: smart_change.pl [options] [origfile...]
Options:
-h, --help display this message
-v, --verbose run verbosely
-n, --no-bump do not bump translation-check headers
+ -m, --modified use list of files from VCS modified files in current tree
+ -c, --commit=ID use list of files from VCS modified files in commit id
-l, --lang=STRING process this language (may be used more than once)
-s, --substitute=REGEXP
Perl regexp applied to source files
@@ -62,6 +64,8 @@ EOT
if (not Getopt::Long::GetOptions(qw(
h|help
v|verbose
+ m|modified
+ c|commit=s
n|no-bump
p|previous
l|lang=s@
@@ -71,6 +75,30 @@ if (not Getopt::Long::GetOptions(qw(
exit(1);
}
+my $VCS = Local::VCS->new();
+
+my @changed_files;
+
+if (not @ARGV and $opt_m) {
+ push @changed_files, $VCS->get_modified_files_from_worktree();
+}
+if (not @ARGV and $opt_c) {
+ push @changed_files, $VCS->get_modified_files_from_revision($opt_c);
+}
+
+if (not @ARGV and @changed_files) {
+ my %english_files;
+ foreach my $changed_file (@changed_files) {
+ next unless $changed_file =~ m{\.(?:wml|src)};
+ next unless $changed_file =~ m{/};
+
+ my $english_file = $changed_file =~ s{^[^/]+}{english}r;
+ $english_files{$english_file} = 1;
+ }
+
+ push @ARGV, sort keys %english_files;
+}
+
$opt_h && usage;
die "Invalid number of arguments\n" unless @ARGV;
@@ -97,7 +125,6 @@ foreach my $argfile (@ARGV) {
$argfile =~ m+^(english.*)/(.*\.(wml|src))+ or die "unknown path '$argfile'";
verbose("File: $argfile");
- my $VCS = Local::VCS->new();
my %file_info = $VCS->file_info($argfile);
my $origrev = $file_info{'cmt_rev'} or die "Can't find revision information for original file $argfile\n";
verbose("Original revision: $origrev");

© 2014-2024 Faster IT GmbH | imprint | privacy policy