aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Ruppert <idl0r@gentoo.org>2013-05-10 19:12:45 +0200
committerChristian Ruppert <idl0r@gentoo.org>2013-05-10 19:14:38 +0200
commit16b7f5c64f149a8009626f75198c3e65e7456e59 (patch)
tree696048331d24b16e45df907f45d80948adf2d3ed
parentFix version replecement of the dist target (diff)
downloadgentoolkit-16b7f5c64f149a8009626f75198c3e65e7456e59.tar.gz
gentoolkit-16b7f5c64f149a8009626f75198c3e65e7456e59.tar.bz2
gentoolkit-16b7f5c64f149a8009626f75198c3e65e7456e59.zip
Fix Copyright check, bug 454782 and some cleanup
-rwxr-xr-xsrc/echangelog/echangelog50
-rwxr-xr-xsrc/echangelog/test/test.sh8
2 files changed, 31 insertions, 27 deletions
diff --git a/src/echangelog/echangelog b/src/echangelog/echangelog
index bf25af7..48007d1 100755
--- a/src/echangelog/echangelog
+++ b/src/echangelog/echangelog
@@ -518,29 +518,28 @@ sub sortfunc($$) {
@ebuilds = grep(/\.ebuild$/, @files);
@files = grep(!/\.ebuild$/, @files);
+my $fh;
if (@ebuilds) {
if ($vcs eq "git") {
- open C, $vcs{$vcs}{diff}." HEAD -- @ebuilds 2>&1 |" or die "Can't run: ".$vcs{$vcs}{diff}."$!\n";
+ open($fh, $vcs{$vcs}{diff}." HEAD -- @ebuilds 2>&1 |") or die "Can't run: ".$vcs{$vcs}{diff}."$!\n";
} else {
- open C, $vcs{$vcs}{diff}." @ebuilds 2>&1 |" or die "Can't run: ".$vcs{$vcs}{diff}."$!\n";
+ open($fh, $vcs{$vcs}{diff}." @ebuilds 2>&1 |") or die "Can't run: ".$vcs{$vcs}{diff}."$!\n";
}
- $_ = <C>;
-
- while (defined $_) {
+ while (defined(my $line = <$fh>)) {
# only possible with cvs
- if (/^$vcs diff: (([^\/]*?)\.ebuild) was removed/) {
+ if ($line =~ m/^$vcs diff: (([^\/]*?)\.ebuild) was removed/) {
mypush(@ebuilds, $1);
}
# We assume GNU diff output format here.
# git format: diff --git a/app-doc/repodoc/metadata.xml b/app-doc/repodoc/metadata.xml
- elsif (/$vcs{$vcs}{regex}/) {
+ elsif ($line =~ m/$vcs{$vcs}{regex}/) {
my ($file, $version) = ($1, $2);
if ($vcs eq "git") {
- while (<C>) {
- last if /^deleted file mode|^index/;
- if (/^new file mode/) {
+ while (defined($line = <$fh>)) {
+ last if $line =~ m/^deleted file mode|^index/;
+ if ($line =~ m/^new file mode/) {
mypush(@ebuilds, $file);
mypush(@new_versions, $version);
last;
@@ -549,12 +548,12 @@ if (@ebuilds) {
}
if ($vcs eq "bzr") {
- if (/^=== added file/) {
+ if ($line =~ m/^=== added file/) {
mypush(@ebuilds, $file);
mypush(@new_versions, $version);
last;
}
- elsif(/^=== renamed file '.+\/([^\/]+\.ebuild)' => '.+\/(([^\/]+)\.ebuild)'/) {
+ elsif($line =~ /^=== renamed file '.+\/([^\/]+\.ebuild)' => '.+\/(([^\/]+)\.ebuild)'/) {
mypush(@ebuilds, $1, $2);
mypush(@new_versions, $3);
last;
@@ -564,31 +563,36 @@ if (@ebuilds) {
# check if more than just copyright date changed.
# skip some lines (vcs dependent)
foreach(1..$vcs{$vcs}{skip}) {
- $_ = <C>;
+ $line = <$fh>;
}
- while (<C>) {
- last if /^[A-Za-z]/;
- if (/^[-+](?!# Copyright)/) {
+
+ my $copy_only = 1;
+ while(defined($line = <$fh>)) {
+ # We just want to check/compare the differences so anything beginning with +/-
+ if ($line =~ m/^[-+](?!# Copyright)/m) {
mypush(@ebuilds, $file);
+ $copy_only = 0;
last;
}
}
- # at this point we've either added $f to @ebuilds or not,
- # and we have the next line in $_ for processing
+ # Only the Copyright has been changed so lets remove the file from the array
+ if ($copy_only) {
+ @ebuilds = grep(!/\Q${file}\E/, @ebuilds);
+ }
+
+ # At this point all ebuilds where more than just the copyright has been changed have been added to @ebuilds.
+ # So lets go ahead with the next diff.
next;
}
- elsif (/^$vcs.*?: (([^\/]*?)\.ebuild) is a new entry/) {
+ elsif ($line =~ m/^$vcs.*?: (([^\/]*?)\.ebuild) is a new entry/) {
mypush(@ebuilds, $1);
mypush(@new_versions, $2);
}
-
- # other cvs output is ignored
- $_ = <C>;
}
}
-close C;
+close($fh);
# Subversion diff doesn't identify new versions. So use the status command
if (($vcs eq "svn" or $vcs eq "hg") and (@ebuilds)) {
diff --git a/src/echangelog/test/test.sh b/src/echangelog/test/test.sh
index 4157d72..74d815f 100755
--- a/src/echangelog/test/test.sh
+++ b/src/echangelog/test/test.sh
@@ -17,9 +17,9 @@ export ECHANGELOG_USER="Just a test <echangelogtest@gentoo.org>"
MD5_INIT="21ac109c53cf02378593a4f613b2bb55"
MD5_PATCH="f3fa1cacae3bf51d6188278e6a5fd0c6"
MD5_REVBUMP="e474aa136f06e2a001320240b2ae92bd"
-MD5_COPYRIGHT="17e3e9a3ec855f5229815cbfd327b634"
-MD5_OBSOLETE="9424da75f53c5212f58cf11a614a97c5"
-MD5_FINAL="3f770e0c13a31653fd0f4ff71598ba6f"
+MD5_COPYRIGHT="9ce45576db5489c4f109ed9ef9ffe05e"
+MD5_OBSOLETE="f0079450e03e69741502776a6b8138dc"
+MD5_FINAL="a3954786368fd92d8466bc65cbf689fc"
UPDATE_MD5=0
@@ -138,7 +138,7 @@ make_test() {
eerror "WRONG MD5_OBSOLETE!"
fi
- echo>>vcstest-0.0.1.ebuild
+ echo "foobar" >> vcstest-0.0.1.ebuild
ech ${echangelog} --vcs $vcs "Revbump...; Just copyright changed; Removed obsolete patch; Modified more then just the copyright."
if [ "${MD5_FINAL}" != "$(md5 ChangeLog MD5_FINAL)" ]; then