Skip to content

Instantly share code, notes, and snippets.

@inem
Last active December 21, 2022 00:36
Show Gist options
  • Save inem/d2b4e04c47289b3ddab09fd28bea579e to your computer and use it in GitHub Desktop.
Save inem/d2b4e04c47289b3ddab09fd28bea579e to your computer and use it in GitHub Desktop.
# Makes git push and creates Merge Request at the same time
# If you follow branch naming convention like "ucp-123/new-authorization", MR title will be "UCP-123 New authorization", which will be cross-linked to Jira
# Make sure to replace "ucp" with your shortcut.
# IMPORTANT PREREQUISITE: to run `git config committer.name <your_gitlab_username>` once, so that it gets used for `make publish!` to assign MR to you
USERNAME := $(shell git config committer.name)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
ticket_pattern := ucp-[0-9][0-9][0-9]
TICKET := $(shell git rev-parse --abbrev-ref HEAD | grep -o '$(ticket_pattern)' | tr [:lower:] [:upper:])
FEATURE_NAME := $(shell git rev-parse --abbrev-ref HEAD | grep -o '$(ticket_pattern)/.*' | cut -d "/" -f 2 | sed -e 's:-: :g' | awk '{print toupper(substr($$0,0,1))tolower(substr($$0,2))}')
publish!:
git commit --allow-empty -m "empty commit"
git push origin $(BRANCH) \
-o merge_request.create \
-o merge_request.target=master \
-o merge_request.assign="$(USERNAME)" \
-o merge_request.label="to-production" \
-o merge_request.title="$(TICKET) $(FEATURE_NAME)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment