Patchwork [RFC,v2,04/15] create-pull-request: rewrite known private URLs to public URLs

login
register
mail settings
Submitter Darren Hart
Date May 16, 2011, 10:26 p.m.
Message ID <8ca2a8e517f83c09ba0f1a591d55b338f24c328a.1305584418.git.dvhart@linux.intel.com>
Download mbox | patch
Permalink /patch/4197/
State New, archived
Headers show

Comments

Darren Hart - May 16, 2011, 10:26 p.m.
Rather than requiring users to have public remotes and private remotes when
their development remotes are ssh based (and therefor unsuitable for a pull
request URL), rewrite the ones we know about from ssh://git@ to git://.

As the remote url vary from remote to remote, do the REMOTE_REPO regex per
remote.

With this infrastructure in place, future patches can augment the list of
known remotes for things like Git Hub, Gitorious, kernel.org, etc.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Cc: Tom Rini <tom_rini@mentor.com>
Cc: Martin Jansa <martin.jansa@gmail.com>
Cc: Otavio Salvador <otavio@ossystems.com.br>
Cc: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 scripts/create-pull-request |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
Joshua Lock - May 16, 2011, 11:40 p.m.
On Mon, 2011-05-16 at 15:26 -0700, Darren Hart wrote:
> Rather than requiring users to have public remotes and private remotes when
> their development remotes are ssh based (and therefor unsuitable for a pull
> request URL), rewrite the ones we know about from ssh://git@ to git://.
> 
> As the remote url vary from remote to remote, do the REMOTE_REPO regex per
> remote.
> 
> With this infrastructure in place, future patches can augment the list of
> known remotes for things like Git Hub, Gitorious, kernel.org, etc.
> 
> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Acked-by: Joshua Lock <josh@linux.intel.com>

> Cc: Tom Rini <tom_rini@mentor.com>
> Cc: Martin Jansa <martin.jansa@gmail.com>
> Cc: Otavio Salvador <otavio@ossystems.com.br>
> Cc: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  scripts/create-pull-request |   14 +++++++++++++-
>  1 files changed, 13 insertions(+), 1 deletions(-)
> 
> diff --git a/scripts/create-pull-request b/scripts/create-pull-request
> index 8f7f767..429421b 100755
> --- a/scripts/create-pull-request
> +++ b/scripts/create-pull-request
> @@ -65,7 +65,19 @@ while getopts "b:hi:m:o:p:r:s:u:" OPT; do
>  			echo "ERROR: git config failed to find a url for '$REMOTE'"
>  			exit 1
>  		fi
> -		REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
> +
> +		# Rewrite known private URLs to public URLs
> +		# Determine the repository name for use in the WEB_URL later
> +		case "$REMOTE_URL" in
> +		ssh://git@git.pokylinux.org*)
> +			REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
> +			REMOTE_URL=${REMOTE_URL/'ssh://git@'/'git://'}
> +			;;
> +		ssh://git@git.yoctoproject.org*)
> +			REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
> +			REMOTE_URL=${REMOTE_URL/"ssh://git@"/"git://"}
> +			;;
> +		esac
>  		# The .git suffix is optional in the URL, drop in for the REPO
>  		REMOTE_REPO=${REMOTE_REPO%.git}
>  		;;

Patch

diff --git a/scripts/create-pull-request b/scripts/create-pull-request
index 8f7f767..429421b 100755
--- a/scripts/create-pull-request
+++ b/scripts/create-pull-request
@@ -65,7 +65,19 @@  while getopts "b:hi:m:o:p:r:s:u:" OPT; do
 			echo "ERROR: git config failed to find a url for '$REMOTE'"
 			exit 1
 		fi
-		REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
+
+		# Rewrite known private URLs to public URLs
+		# Determine the repository name for use in the WEB_URL later
+		case "$REMOTE_URL" in
+		ssh://git@git.pokylinux.org*)
+			REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
+			REMOTE_URL=${REMOTE_URL/'ssh://git@'/'git://'}
+			;;
+		ssh://git@git.yoctoproject.org*)
+			REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
+			REMOTE_URL=${REMOTE_URL/"ssh://git@"/"git://"}
+			;;
+		esac
 		# The .git suffix is optional in the URL, drop in for the REPO
 		REMOTE_REPO=${REMOTE_REPO%.git}
 		;;