From 97d0ca56c28b81fc8534dc09a4d6b25775218ec0 Mon Sep 17 00:00:00 2001 From: agriffis Date: Wed, 17 Mar 2004 04:37:52 +0000 Subject: [PATCH] make ebuild copyright dates work svn path=/; revision=91 --- trunk/src/echangelog/ChangeLog | 4 ++ trunk/src/echangelog/README | 2 +- trunk/src/echangelog/echangelog | 89 +++++++++++++++++++---------- trunk/src/echangelog/echangelog.pod | 2 +- 4 files changed, 65 insertions(+), 32 deletions(-) diff --git a/trunk/src/echangelog/ChangeLog b/trunk/src/echangelog/ChangeLog index 72f706d..5065bd8 100644 --- a/trunk/src/echangelog/ChangeLog +++ b/trunk/src/echangelog/ChangeLog @@ -1,3 +1,7 @@ +16 Mar 2004 Aron Griffis + * Make Feb 17 behavior work without Feb 20 bug :-) + * Release as version 0.2.0 + 20 Feb 2004 Aron Griffis * Only update copyrights on modified ebuilds, otherwise if you run echangelog again, it reports that all the ebuilds have been updated! diff --git a/trunk/src/echangelog/README b/trunk/src/echangelog/README index 5bb0444..7db8869 100644 --- a/trunk/src/echangelog/README +++ b/trunk/src/echangelog/README @@ -1,5 +1,5 @@ Package : echangelog -Version : 0.1.0 +Version : 0.2.0 Author : See AUTHORS MOTIVATION diff --git a/trunk/src/echangelog/echangelog b/trunk/src/echangelog/echangelog index b8afe63..e2d6c73 100644 --- a/trunk/src/echangelog/echangelog +++ b/trunk/src/echangelog/echangelog @@ -19,9 +19,10 @@ $Text::Wrap::columns = 79; $Text::Wrap::unexpand = 0; # Global variables -my @files = (); +my (@files) = (); +my (@ebuilds) = (); my ($input, $entry, $user, $date, $text, $version, $year); -my %versions = (); +my (%versions) = (); # Read the current ChangeLog if (-f 'ChangeLog') { @@ -50,37 +51,62 @@ if (-f 'ChangeLog') { } # Figure out what has changed around here -open C, 'cvs diff --brief 2>&1 |' or die "Can't run cvs diff: $!\n"; +open C, 'cvs -n up 2>&1 |' or die "Can't run cvs -n up: $!\n"; while () { - /ChangeLog/ and next; - if (/^cvs.*?: (([^\/]*?)\.ebuild) was removed/) { - push @files, $1; - $versions{$2} = 0; # existing ebuild that was removed - } - elsif (/^cvs.*?: (\S+) was removed/) { - push @files, $1; - # existing file that has been removed - } - elsif (/^Index: (([^\/]*?)\.ebuild)\s*$/) { - push @files, $1; - $versions{$2} = 0; # existing ebuild that has changed - } - elsif (/^Index: (\S+)/) { - push @files, $1; - # existing file, but not an ebuild, so no %version entry - } - elsif (/^cvs.*?: (([^\/]*?)\.ebuild) is a new entry/) { - push @files, $1; - $versions{$2} = -1; # new ebuild, will create a new entry - } - elsif (/^cvs.*?: (\S+) is a new entry/) { - push @files, $1; - # new file, but not an ebuild, so no %version entry + /ChangeLog/ and next; + /^[MCAR] (\S+)/ and push @files, $1; +} + +# Forget ebuilds that only have changed copyrights, unless that's all +# the changed files we have +@ebuilds = grep /\.ebuild$/, @files; +@files = grep !/\.ebuild$/, @files; +print "files = @files\n"; +print "ebuilds = @ebuilds\n"; +if (@ebuilds) { + open C, "cvs diff -U 0 @ebuilds 2>&1 |" or die "Can't run cvs diff: $!\n"; + $_ = ; + while (defined $_) { + if (/^cvs diff: (([^\/]*?)\.ebuild) was removed/) { + push @files, $1; + $versions{$2} = 0; # existing ebuild that was removed + } + elsif (/^Index: (([^\/]*?)\.ebuild)\s*$/) { + my ($f, $v) = ($1, $2); + # check if more than just copyright date changed. + # skip some lines + $_ = ; # ==================================== + $_ = ; # RCS file: ... + $_ = ; # retrieving revision + $_ = ; # diff -u ... + $_ = ; # --- vim-6.2-r6.ebuild + $_ = ; # +++ vim-6.2-r6.ebuild + while () { + last if /^[A-Za-z]/; + if (/^[-+](?!# Copyright)/) { + push @files, $f; + $versions{$2} = $v; # existing ebuild that has changed + last; + } + } + # at this point we've either added $f to @files or not, + # and we have the next line in $_ for processing + next; + } + elsif (/^cvs.*?: (([^\/]*?)\.ebuild) is a new entry/) { + push @files, $1; + $versions{$2} = -1; # new ebuild, will create a new entry + } + # other cvs output is ignored + $_ = ; } - # other cvs output is ignored } close C; +# Check if we have any files left, otherwise re-insert ebuild list +# (of course, both might be empty anyway) +@files = @ebuilds unless (@files); + # Allow ChangeLog entries with no changed files, but give a fat warning unless (@files) { print "**\n\n"; @@ -184,10 +210,12 @@ print O $text or die "Can't write ChangeLog.new: $!\n"; close O or die "Can't close ChangeLog.new: $!\n"; # Update affected ebuild copyright dates -for my $e (grep /\.ebuild$/, @files) { +#for my $e (grep /\.ebuild$/, @files) { # Update all ebuild copyright dates -- according to Mr_Bones_ this is # the right thing to do -#for my $e (<*.ebuild>) { +opendir D, '.' or die "Can't opendir .: $!\n"; +for my $e (grep /\.ebuild$/, readdir D) { + print "updating $e\n"; my ($etext, $netext); open E, "<$e" or warn("Can't read $e to update copyright year\n"), next; { local $/ = undef; $etext = ; } @@ -206,6 +234,7 @@ for my $e (grep /\.ebuild$/, @files) { system "diff -U 0 $e $e.new"; rename "$e.new", $e or warn("Can't rename $e.new: $!\n"); } +close D; # Move things around and show the ChangeLog diff system 'diff -Nu ChangeLog ChangeLog.new'; diff --git a/trunk/src/echangelog/echangelog.pod b/trunk/src/echangelog/echangelog.pod index 45c9148..192af8d 100644 --- a/trunk/src/echangelog/echangelog.pod +++ b/trunk/src/echangelog/echangelog.pod @@ -30,7 +30,7 @@ are computed correctly, then edit and change "blah" to your preferred text. In addition to updating the ChangeLog, echangelog will automatically -update the copyright year of any affected ebuilds, as well as the +update the copyright year of all out-of-date ebuilds, as well as the ChangeLog itself. These updates are included in the diff displayed by echangelog when it finishes its work. -- 2.26.2