[pkg-perl-tools] 04/05: scripts/upstream-repo: add -u (update) option

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 f936a20178d0cc6029ee563f7d8a0db272865582
Author: gregor herrmann <gregoa at debian.org>
Date:   Tue Jun 28 10:44:55 2016 +0200

    scripts/upstream-repo: add -u (update) option
    
    to change the URL of the Git remote 'upstream-repo' in the local clone.
---
 scripts/upstream-repo | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/scripts/upstream-repo b/scripts/upstream-repo
index 9147c41..336c5e7 100755
--- a/scripts/upstream-repo
+++ b/scripts/upstream-repo
@@ -30,16 +30,21 @@ checkrepourl() {
 }
 
 CREATE=1
+UPDATE=0
 REPO=
 
 # command line arguments
 # -g don't create debian/upstream/metadata
+# -u update url of remote "upstream-repo"
 #    to be used from .mrconfig
-while getopts g OPTS; do
+while getopts gu OPTS; do
 	case "$OPTS" in
 		g)
 			CREATE=0
 			;;
+		u)
+			UPDATE=1
+			;;
 		*)
 			;;
 	esac
@@ -82,7 +87,20 @@ if ! git remote show | grep -qx upstream-repo ; then
 	fi
 else
 	warn "Found Git remote 'upstream-repo':"
-	git remote --verbose show upstream-repo
+	git remote --verbose show upstream-repo || true
+	if [ "$UPDATE" -eq "1" ] ; then
+		OLDREPO=$(git remote get-url upstream-repo)
+		repofromcopyright
+		[ -n "$REPO" ] || repofrommetadata
+		if [ -n "$REPO" -a "$OLDREPO" != "$REPO" ] ; then
+			checkrepourl
+			if [ -n "$REPO" ] ; then
+				git remote set-url upstream-repo "$REPO"
+				warn "Updating Git remote 'upstream-repo' to use URL '$REPO' ..."
+				git remote --verbose show upstream-repo
+			fi
+		fi
+	fi
 	git fetch upstream-repo
 fi
 
@@ -93,7 +111,7 @@ dpt-upstream-repo - add upstream Git repository as git remote upstream-repo
 
 =head1 SYNOPSIS
 
-B<dpt upstream-repo> [-g]
+B<dpt upstream-repo> [-g|-u]
 
 =head1 DESCRIPTION
 
@@ -120,6 +138,11 @@ The letter B<g> is used for historical reasons because initially this
 option only suppressed the automatic committing to the B<g>it
 repository.
 
+=item B<-u>
+
+Update the URL of the I<upstream-repo> B<git remote>.
+The value is read from the same places as for the initial creation.
+
 =back
 
 =head1 SEE ALSO

-- 
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