[pkg-perl-tools] 03/05: break out repo url handling into functions

gregor herrmann gregoa at debian.org
Tue Jun 28 08:46:23 UTC 2016


This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to branch master
in repository pkg-perl-tools.

commit 079d815c7906201e48e4a14f6893ec9fda81b6a6
Author: gregor herrmann <gregoa at debian.org>
Date:   Tue Jun 28 10:30:04 2016 +0200

    break out repo url handling into functions
    
    which we will reuse later
    
    Git-Dch: ignore
---
 scripts/upstream-repo | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/scripts/upstream-repo b/scripts/upstream-repo
index 7b1431b..9147c41 100755
--- a/scripts/upstream-repo
+++ b/scripts/upstream-repo
@@ -14,7 +14,23 @@ warn() {
 	echo "$1" >&2
 }
 
+repofromcopyright() {
+	REPO=$(perl -MDebian::Copyright -E '$c = Debian::Copyright->new(); $c->read("debian/copyright"); say $c->header()->Source' | grep -oE "git(?:+ssh)?:.+$" || true)
+}
+
+repofrommetadata() {
+	# XXX use something better than awk to parse this YAML file?
+	REPO=$(awk '/^Repository:\s*.+/ {print $2;}' debian/upstream/metadata || true)
+}
+
+checkrepourl() {
+	if ! GIT_ASKPASS=/bin/true git ls-remote "$REPO" >/dev/null 2>&1; then
+		REPO=
+	fi
+}
+
 CREATE=1
+REPO=
 
 # command line arguments
 # -g don't create debian/upstream/metadata
@@ -40,7 +56,7 @@ if ! git remote show | grep -qx upstream-repo ; then
 	# case 1: Git URL in d/copyright's Source paragraph
 	# XXX Eliminate call to grep?
 	# XXX this does not work for https://foo.git URLs.
-	REPO=$(perl -MDebian::Copyright -E '$c = Debian::Copyright->new(); $c->read("debian/copyright"); say $c->header()->Source' | grep -oE "git(?:+ssh)?:.+$" || true)
+	repofromcopyright
 
 	# case 2: Repository in d/upstream/metadata
 	if [ -z "$REPO" -a ! -e debian/upstream/metadata -a "$CREATE" -eq "1" ] ; then
@@ -53,13 +69,10 @@ if ! git remote show | grep -qx upstream-repo ; then
 		git commit -m "Update debian/changelog" -m "Gbp-Dch: Ignore"
 	fi
 	if [ -z "$REPO" -a -e debian/upstream/metadata ] ; then
-		# XXX use something better than awk to parse this YAML file?
-		URL=$(awk '/^Repository:\s*.+/ {print $2;}' debian/upstream/metadata || true)
-		if GIT_ASKPASS=/bin/true git ls-remote ${URL} >/dev/null 2>&1; then
-			REPO=${URL}
-		fi
+		repofrommetadata
 	fi
 
+	checkrepourl
 	if [ -n "$REPO" ] ; then
 		warn "Adding Git remote 'upstream-repo' with URL '$REPO' ..."
 		git remote add upstream-repo "$REPO"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/pkg-perl-tools.git



More information about the Pkg-perl-cvs-commits mailing list