create-pull-request: generalize the repository URL parsing
The existing REMOTE_URL and REMOTE_REPO parsing made assumptions regarding the git URL format used for the known repository types. In fact, both of these ssh URL formats are valid for all the known repositories. Specifically: ssh://git@server/repository/path git@server:repository/path Generalize the parsing to work with each of these for all push URLs matching *@*. Tested with the following URLs: ssh://git@git.pokylinux.org/poky-contrib ssh://git@git.pokylinux.org/poky-contrib.git git@git.pokylinux.org:poky-contrib git@git.pokylinux.org:poky-contrib.git (From OE-Core rev: 861c288e353e917374de938c4e5e927e116cd56c) Signed-off-by: Darren Hart <dvhart@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
c2d187065e
commit
567f171920
|
@ -97,28 +97,22 @@ while getopts "b:chi:m:o:p:r:s:u:" OPT; do
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Rewrite known private URLs to public URLs
|
# Rewrite private URLs to public URLs
|
||||||
# Determine the repository name for use in the WEB_URL later
|
# Determine the repository name for use in the WEB_URL later
|
||||||
case "$REMOTE_URL" in
|
case "$REMOTE_URL" in
|
||||||
ssh://git@git.pokylinux.org*)
|
*@*)
|
||||||
REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
|
USER_RE="[A-Za-z0-9_.@][A-Za-z0-9_.@-]*\$\?"
|
||||||
REMOTE_URL=${REMOTE_URL/'ssh://git@'/'git://'}
|
PROTO_RE="[a-z][a-z]*://"
|
||||||
|
GIT_RE="\(^\($PROTO_RE\)\?$USER_RE@\)\([^:/]*\)[:/]\(.*\)"
|
||||||
|
REMOTE_URL=${REMOTE_URL%.git}
|
||||||
|
REMOTE_REPO=$(echo $REMOTE_URL | sed "s#$GIT_RE#\4#")
|
||||||
|
REMOTE_URL=$(echo $REMOTE_URL | sed "s#$GIT_RE#git://\3/\4#")
|
||||||
;;
|
;;
|
||||||
ssh://git@git.yoctoproject.org*)
|
*)
|
||||||
REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
|
echo "WARNING: Unrecognized remote URL: $REMOTE_URL"
|
||||||
REMOTE_URL=${REMOTE_URL/"ssh://git@"/"git://"}
|
echo " The pull and browse URLs will likely be incorrect"
|
||||||
;;
|
|
||||||
*ssh://git@git.openembedded.org*)
|
|
||||||
REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
|
|
||||||
REMOTE_URL=${REMOTE_URL/"ssh://git@"/"git://"}
|
|
||||||
;;
|
|
||||||
git@github.com:*)
|
|
||||||
REMOTE_REPO=$(echo $REMOTE_URL | sed 's#.*:\(.*\)\(\.git\)$#\1#')
|
|
||||||
REMOTE_URL=${REMOTE_URL/"git@github.com:"/"git://github.com/"}
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
# The .git suffix is optional in the URL, drop in for the REPO
|
|
||||||
REMOTE_REPO=${REMOTE_REPO%.git}
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -134,6 +128,7 @@ fi
|
||||||
|
|
||||||
|
|
||||||
# Set WEB_URL from known remotes
|
# Set WEB_URL from known remotes
|
||||||
|
WEB_URL=""
|
||||||
case "$REMOTE_URL" in
|
case "$REMOTE_URL" in
|
||||||
*git.yoctoproject.org*)
|
*git.yoctoproject.org*)
|
||||||
WEB_URL="http://git.yoctoproject.org/cgit.cgi/$REMOTE_REPO/log/?h=$BRANCH"
|
WEB_URL="http://git.yoctoproject.org/cgit.cgi/$REMOTE_REPO/log/?h=$BRANCH"
|
||||||
|
|
Loading…
Reference in New Issue