Last active
July 30, 2019 14:31
-
-
Save LeZuse/513f7877db008aea316d0f3b7e160fb7 to your computer and use it in GitHub Desktop.
List My GitLab Merge Requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mrs() { | |
[ -z "$GITLAB_TOKEN" ] && \ | |
echo 'Missing GITLAB_TOKEN env var. See https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#creating-a-personal-access-token' && \ | |
return 1 | |
# download from GL API, process with jq and colorize with sed replace | |
curl https://gitlab.com/api/v4/merge_requests?private_token=$GITLAB_TOKEN\&state=opened\&sort=desc\&scope=assigned_to_me 2>/dev/null | \ | |
jq --raw-output '.[] | "#" + (.iid | tostring) + " " + .title + " @" + .author.username + " | " + (.labels | join(", ")) + " \n 👉 " + .web_url + "\n"' | \ | |
sed "s,.*https.*,$(tput setaf 6)&$(tput sgr0)," | \ | |
sed -e "s/\(#[0-9]*\)\(.*\)\(@[a-zA-Z0-9-]*\) |\(.*\)/$(tput setaf 220)\1$(tput sgr0)\2$(tput setaf 7)\3 $(tput setab 4)\4$(tput sgr0)/g" | |
# sed -e "s/.*|\(.*\)/$(tput setab 4)$(tput setaf 7)\1$(tput sgr0)/" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment