View | Details | Raw Unified
Collapse All | Expand All

(-) echangelog (-30 / +103 lines)
 Lines 20-26    Link Here 
# Global variables
# Global variables
my (@files, @ebuilds, @conflicts, @trivial, @unknown, @new_versions, %actions);
my (@files, @ebuilds, @conflicts, @trivial, @unknown, @new_versions, %actions);
my ($input, $editor, $entry, $user, $date, $text, $version, $year);
my ($input, $editor, $entry, $user, $date, $text, $version, $year, $vcs);
my %vcs =     ( cvs => { diff => "cvs -f -U0 diff",
			 status => "cvs -fn up",
			 add => "cvs -f add",
			 skip => 6,
			 regex => qr/^Index: ()(([^\/]*?)\.ebuild)\s*$/ },
		svn => { diff => "svn diff -N",
			 status => "svn status",
			 add => "svn add",
			 skip => 6,
			 regex => qr/^Index: ()(([^\/]*?)\.ebuild)\s*$/ },
		git => { diff => "git diff",
			 status => "git diff-index HEAD --name-status",
			 add => "git add",
			 skip => 4,
			 regex => qr/^diff \-\-git \S*\/((\S*)\.ebuild)/ }
);
# Figure out what kind of repo we are in.
if ( -d "CVS" ) {
   $vcs = "cvs";
} elsif ( -d '.svn' ) {
    $vcs = "svn";
} elsif ( open GIT, "git rev-parse --git-dir |" ) {
    $vcs = "git";
    close GIT;
} else {
    die "No CVS, .git, .svn directories found, what kind of repo is this?";
}
# Read the current ChangeLog
# Read the current ChangeLog
if (-f 'ChangeLog') {
if (-f 'ChangeLog') {
 Lines 30-37    Link Here 
} else {
} else {
    # No ChangeLog here, maybe we should make one...
    # No ChangeLog here, maybe we should make one...
    if (<*.ebuild>) {
    if (<*.ebuild>) {
        open I, '<../../skel.ChangeLog' 
	open C, "portageq envvar PORTDIR |" or die "Can't find PORTDIR";
            or die "Can't open ../../skel.ChangeLog for input: $!\n";
	my ($new) = <C>;
	close C;
	$new =~ s/\s+$//;
        open I, "< $new/skel.ChangeLog" 
            or die "Can't open $new/skel.ChangeLog for input: $!\n";
        { local $/ = undef; $text = <I>; }
        { local $/ = undef; $text = <I>; }
        close I;
        close I;
        my ($cwd) = getcwd();
        my ($cwd) = getcwd();
 Lines 46-64    Link Here 
    }
    }
}
}
# Figure out what has changed around here
# Figure out what has changed around here
open C, 'cvs -fn up 2>&1 |' or die "Can't run cvs -fn up: $!\n";
open C, $vcs{$vcs}{status}.' 2>&1 |' or die "Can't run ".$vcs{$vcs}{status}.": $!\n";
while (<C>) {
while (<C>) {
    if (/^C (\S+)/) {
    if (/^C\s+(\S+)/) {
        push @conflicts, $1; 
        if($vcs eq "git") {
            my $filename = $2;
            $filename =~ /\S*\/(\S*)/;
	    if( -d $1 ) {
		next;
	    }
            push @conflicts, $1;
            next; 
        }
        push @conflicts, $1;
        next;
        next;
    } elsif (/^\? (\S+)/) {
    } elsif (/^\?\s+(\S+)/) {
        push @unknown, $1;
        if($vcs eq "git") {
            my $filename = $2;
            $filename =~ /\S*\/(\S*)/;
	    if( -d $1 ) {
		next;
	    }
            push @unknown, $1;
            next; 
        } else {
            push @unknown, $1;
        }
        $actions{$1} = '+';
        $actions{$1} = '+';
        next;
        next;
    } elsif (/^([ARM]) (\S+)/) {
    } elsif (/^([ARMD])\s+(\S+)/) {        
        push @files, $2;
        my ($status, $filename) = ($1,$2);
        ($actions{$2} = $1) =~ tr/ARM/+-/d;
        if($vcs eq "git") {
            $filename =~ /\S*\/(\S*)/;
	    $filename = $1;
        }
	if( -d $filename ) {
	    next;
	}
        push @files, $filename;
        ($actions{$filename} = $status) =~ tr/ARDM/+--/d;
    }
    }
}
}
 Lines 66-71    Link Here 
@files = grep { 
@files = grep { 
    !/files.digest|Manifest|ChangeLog/ or do { push @trivial, $_; 0; }
    !/files.digest|Manifest|ChangeLog/ or do { push @trivial, $_; 0; }
} @files;
} @files;
@unknown = grep { 
@unknown = grep { 
    !/files.digest|Manifest|ChangeLog/ or do { push @trivial, $_; 0; }
    !/files.digest|Manifest|ChangeLog/ or do { push @trivial, $_; 0; }
} @unknown;
} @unknown;
 Lines 73-79    Link Here 
# Don't allow any conflicts
# Don't allow any conflicts
if (@conflicts) {
if (@conflicts) {
    print STDERR <<EOT;
    print STDERR <<EOT;
Cvs reports the following conflicts.  Please resolve them before
$vcs reports the following conflicts.  Please resolve them before
running echangelog.
running echangelog.
EOT
EOT
    print STDERR map "C $_\n", @conflicts;
    print STDERR map "C $_\n", @conflicts;
 Lines 84-90    Link Here 
# out above)
# out above)
if (@unknown) {
if (@unknown) {
    print STDERR <<EOT;
    print STDERR <<EOT;
Cvs reports the following unknown files.  Please use "cvs add" before
$vcs reports the following unknown files.  Please use "$vcs add" before
running echangelog, or remove the files in question.
running echangelog, or remove the files in question.
EOT
EOT
    print STDERR map "? $_\n", @unknown;
    print STDERR map "? $_\n", @unknown;
 Lines 177-201    Link Here 
# Forget ebuilds that only have changed copyrights, unless that's all
# Forget ebuilds that only have changed copyrights, unless that's all
# the changed files we have
# the changed files we have
@ebuilds = grep /\.ebuild$/, @files;
@ebuilds = grep /\.ebuild$/, @files;
@files = grep !/\.ebuild$/, @files;
@files = grep !/\.ebuild$/, @files;
if (@ebuilds) {
if (@ebuilds) {
    open C, "cvs -f diff -U0 @ebuilds 2>&1 |" or die "Can't run cvs diff: $!\n";
    if ($vcs eq "git") {
    	open C, $vcs{$vcs}{diff}." 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";
    }
    $_ = <C>;
    $_ = <C>;
    while (defined $_) {
    while (defined $_) {
        if (/^cvs diff: (([^\/]*?)\.ebuild) was removed/) { 
	# only possible with cvs
        if (/^$vcs diff: (([^\/]*?)\.ebuild) was removed/) { 
            push @files, $1;
            push @files, $1;
        }
        }
        elsif (/^Index: (([^\/]*?)\.ebuild)\s*$/) { 
            my ($f, $v) = ($1, $2);
	# 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}/) {
            my ($f) = ($1);
            # file was removed from git 
	    if (/^deleted file mode/) {
		    $_ = <C>; # just eat the line
            }
            # check if more than just copyright date changed.
            # check if more than just copyright date changed.
            # skip some lines
            # skip some lines (vcs dependent)
            $_ = <C>;	# ====================================
	    foreach(1..$vcs{$vcs}{skip}){
            $_ = <C>;	# RCS file: ...
	            $_ = <C>;
            $_ = <C>;	# retrieving revision
	    }
            $_ = <C>;	# diff -u ...
            $_ = <C>;	# --- vim-6.2-r6.ebuild
            $_ = <C>;	# +++ vim-6.2-r6.ebuild
            while (<C>) {
            while (<C>) {
                last if /^[A-Za-z]/;
                last if /^[A-Za-z]/;
                if (/^[-+](?!# Copyright)/) {
                if (/^[-+](?!# Copyright)/) {
 Lines 207-213    Link Here 
            # and we have the next line in $_ for processing
            # and we have the next line in $_ for processing
            next;
            next;
        }
        }
        elsif (/^cvs.*?: (([^\/]*?)\.ebuild) is a new entry/) { 
        elsif (/^$vcs*?: (([^\/]*?)\.ebuild) is a new entry/) { 
            push @files, $1;
            push @files, $1;
            push @new_versions, $2;  # new ebuild, will create a new entry
            push @new_versions, $2;  # new ebuild, will create a new entry
        }
        }
 Lines 334-340    Link Here 
# Update affected ebuild copyright dates.  There is no reason to update the
# Update affected ebuild copyright dates.  There is no reason to update the
# copyright lines on ebuilds that haven't changed.  I verified this with an IP
# copyright lines on ebuilds that haven't changed.  I verified this with an IP
# lawyer.
# lawyer.
for my $e (grep { /\.ebuild$/ && -e } @files) {
for my $e (grep /\.ebuild$/, @files) {
    my ($etext, $netext);
    my ($etext, $netext);
    open E, "<$e" or warn("Can't read $e to update copyright year\n"), next;
    open E, "<$e" or warn("Can't read $e to update copyright year\n"), next;
    { local $/ = undef; $etext = <E>; }
    { local $/ = undef; $etext = <E>; }
 Lines 360-368    Link Here 
# Okay, now we have a starter ChangeLog to work with.
# Okay, now we have a starter ChangeLog to work with.
# The text will be added just like with any other ChangeLog below.  
# The text will be added just like with any other ChangeLog below.  
# Add the new ChangeLog to cvs before continuing.
# Add the new changelog to vcs, maybe it already is added, but who cares right?
if (open F, "CVS/Entries") {
system("$vcs{$vcs}{add} ChangeLog 2>&1 >> /dev/null")
    system("cvs -f add ChangeLog") unless (scalar grep /^\/ChangeLog\//, <F>);
}
# vim:sw=4 ts=8 expandtab
# vim:sw=4 ts=8 expandtab