Commit 95495ff6 authored by Brad King's avatar Brad King

git-gitlab-push: Print follow-up instructions and links for user

If the user pushes to the expected GitLab repository, extract their
username and use it to print URLs useful for them to follow up in
GitLab.
parent 35e3b8d0
......@@ -20,6 +20,24 @@ OPTIONS_SPEC=
SUBDIRECTORY_OK=Yes
. "$(git --exec-path)/git-sh-setup"
egrep-q() {
egrep "$@" >/dev/null 2>/dev/null
}
# Load the project configuration.
gitlab_configured='' &&
config="${BASH_SOURCE%/*}/config" &&
protocol=$(git config -f "$config" --get gitlab.protocol ||
echo "https") &&
host=$(git config -f "$config" --get gitlab.host) &&
site=$(git config -f "$config" --get gitlab.site ||
echo "$protocol://$host") &&
group_path=$(git config -f "$config" --get gitlab.group-path) &&
project_path=$(git config -f "$config" --get gitlab.project-path) &&
gitlab_pushurl=$(git config --get remote.gitlab.pushurl ||
git config --get remote.gitlab.url) &&
gitlab_configured=1
#-----------------------------------------------------------------------------
remote=''
......@@ -70,5 +88,25 @@ echo "Pushing to $remote"
push_stdout=$(git push --porcelain $dry_run "$remote" $refspecs); push_exit=$?
echo "$push_stdout"
# Tell the user what to do next with the topic in GitLab.
if test -z "$no_topic" &&
test "$push_exit" -eq 0 &&
test "$remote" = "gitlab" &&
test -n "$gitlab_configured" &&
echo "$gitlab_pushurl" | egrep-q "$host[^/:]*[/:][^/]*/$project_path\\.git$"; then
userpath="${gitlab_pushurl%/*.git}" &&
username="${userpath##*[/:]}" &&
echo '
The topic has been pushed to your fork in GitLab. Visit
'"$site/$username/$project_path/tree/$topic"'
to see the files. Visit
'"$site/$username/$project_path/merge_requests/new"'
to create a Merge Request if there is not one already.'
fi
# Reproduce the push exit code.
exit $push_exit
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment