Last active
March 9, 2017 19:28
-
-
Save var-bin/80a62d216d79f34e1aa3c150a7cd0274 to your computer and use it in GitHub Desktop.
Create diff for current branch and put it in the file. Use Jira API to add diff to task. Repository https://github.com/var-bin/terminalForCoder__WSD
This file contains hidden or 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
#!/bin/bash | |
PATH_TO_DIFF_DIR="${HOME}/diff/" | |
FILE_EXTENTION=".diff" | |
USER_NAME="<user_name>" | |
USER_PASSWORD="<user_password>" | |
PROJECT_NAME="<project_name>" | |
# if "$1" is empty | |
if [ -z "$1" ] | |
then | |
echo "Please, specify an issue ID" | |
exit 0 | |
fi | |
issue_id="$1" | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
# Get the first line of git remote output and cut a path to repository | |
repository=$(git remote -v | head -n1 | sed "s/^origin.*\/\(.*\)\.git\s(.*)/\1/") | |
file_name="${branch}-${repository}${FILE_EXTENTION}" | |
# path to diff directory with <filename>.diff | |
path_to_diff="${PATH_TO_DIFF_DIR}${file_name}" | |
diffMaster() { | |
git diff "origin/master origin/${branch}" > "$path_to_diff" | |
} | |
attachDiff() { | |
curl -D -u "${USER_NAME}":"${USER_PASSWORD}" -X POST -H "X-Atlassian-Token: no-check" -F "file=@${path_to_diff};type=text/x-diff" "https://jira.${PROJECT_NAME}.com/rest/api/2/issue/${issue_id}/attachments" | |
} | |
diffMaster && attachDiff | |
# Usage: cd <repo_name> && fast_diff_v2.sh <issue_id> | |
# <issue_id> should include your company prefix (ABC, XYZ, XX, etc.) | |
# At instance, "./fast_diff_v2.sh XYZ-135" will try to attach diff to | |
# https://jira.<project_name>.com/browse/XYZ-135 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment