From f08ba2a9455b6af64faa0ce97831a1eca47a093a Mon Sep 17 00:00:00 2001 From: idl0r Date: Sat, 12 Sep 2009 11:50:43 +0000 Subject: [PATCH] Cleanup VCS detection. svn path=/trunk/gentoolkit-dev/; revision=681 --- ChangeLog | 1 + src/echangelog/echangelog | 63 ++++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50bf5ec..4905c24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2009-12-09: Christian Ruppert * src/echangelog/echangelog: Fix bug 284657, thanks to Andrew Gaffney . + Cleanup VCS detection. 2009-09-09: Christian Ruppert * src/imlate/imlate: Bump to 0.0.4. diff --git a/src/echangelog/echangelog b/src/echangelog/echangelog index 83561aa..039e5f3 100755 --- a/src/echangelog/echangelog +++ b/src/echangelog/echangelog @@ -193,39 +193,42 @@ usage() if $opt_help; version() if $opt_version; # Figure out what kind of repo we are in. -# TODO: we might also check svn/cvs more strict. -if ( -d "CVS" ) { - $vcs = "cvs"; -} elsif ( -d '.svn' ) { - $vcs = "svn"; -} else { - # Respect $PATH while looking for git - if (getenv("PATH")) { - foreach my $path ( split(":", getenv("PATH")) ) { - if ( -X "$path/bzr" ) { - open(BZR, '-|', "${path}/bzr root 2>/dev/null"); - $vcs = "bzr" if defined(); - close(BZR); - last if $vcs; - } - if ( -X "$path/git" ) { - open(GIT, '-|', "${path}/git rev-parse --git-dir 2>/dev/null"); - $vcs = "git" if defined(); - close(GIT); - last if $vcs; - } - if ( -X "$path/hg" ) { - open(HG, '-|', "${path}/hg root 2>/dev/null"); - $vcs = "hg" if defined(); - close(HG); - last if $vcs; - } +# Respect $PATH while looking for the VCS +if (getenv("PATH")) { + foreach my $path ( split(":", getenv("PATH")) ) { + if ( -X "${path}/bzr" ) { + open(BZR, '-|', "${path}/bzr root 2>/dev/null"); + $vcs = "bzr" if defined(); + close(BZR); + last if $vcs; + } + if ( -X "${path}/cvs" ) { + $vcs = "cvs" if -d "CVS"; + last if $vcs; + } + if ( -X "${path}/git" ) { + open(GIT, '-|', "${path}/git rev-parse --git-dir 2>/dev/null"); + $vcs = "git" if defined(); + close(GIT); + last if $vcs; + } + if ( -X "${path}/hg" ) { + open(HG, '-|', "${path}/hg root 2>/dev/null"); + $vcs = "hg" if defined(); + close(HG); + last if $vcs; + } + if ( -X "${path}/svn" ) { + $vcs = "svn" if -d ".svn"; + last if $vcs; } } +} - if ( ! $vcs ) { - die "No CVS, .git, .svn directories found, what kind of repo is this?"; - } +if ( ! $vcs ) { + print STDERR "Either no CVS, .git, .svn, ... directories found, the specific VCS has not been\n"; + print STDERR "installed or you don't have execute rights!\n"; + exit(1); } # Read the current ChangeLog -- 2.26.2