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
parent 35e3b8d0
......@@ -20,6 +20,24 @@ OPTIONS_SPEC=
. "$(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 &&
site=$(git config -f "$config" --get ||
echo "$protocol://$host") &&
group_path=$(git config -f "$config" --get &&
project_path=$(git config -f "$config" --get gitlab.project-path) &&
gitlab_pushurl=$(git config --get remote.gitlab.pushurl ||
git config --get remote.gitlab.url) &&
......@@ -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
to see the files. Visit
to create a Merge Request if there is not one already.'
# 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