11#! /bin/bash
22
3+ PATH_TO_DIFF_DIR=" ${HOME} /diff/"
4+ FILE_EXTENTION=" .diff"
5+
6+ USER_NAME=" <ipa_user_name>"
7+ USER_PASSWORD=" <ipa_user_password>"
8+ PROJECT_NAME=" <project_name>"
9+
10+ # if "$1" is empty
311if [ -z " $1 " ]
412then
513 echo " Please, specify an issue ID"
@@ -11,19 +19,21 @@ branch=$(git rev-parse --abbrev-ref HEAD)
1119
1220# Get the first line of git remote output and cut a path to repository
1321repository=$( git remote -v | head -n1 | sed " s/^origin.*\/\(.*\)\.git\s(.*)/\1/" )
22+ file_name=" ${branch} -${repository}${FILE_EXTENTION} "
1423
15- path_to_diff=" ${HOME} /<path_to_diff_directory>${branch} -${repository} .diff"
24+ # path to diff directory with <filename>.diff
25+ path_to_diff=" ${PATH_TO_DIFF_DIR}${file_name} "
1626
17- diff_live () {
18- git diff " origin/live.. master/${branch} " > " $path_to_diff "
27+ diff_master () {
28+ git diff " origin/master origin /${branch} " > " $path_to_diff "
1929}
2030
21- attach_diff () {
22- curl -D- -u " <ipa_username> " :" <ipa_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"
31+ attach_diff () {
32+ 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"
2333}
2434
25- diff_live && attach_diff
35+ diff_master && attach_diff
2636
27- # Usage: cd <repo_name> && attach_diff <issue_id>
37+ # Usage: cd <repo_name> && fast_diff_v2.sh <issue_id>
2838# <issue_id> should include your company prefix (ABC, XYZ, XX, etc.)
29- # At instance, "attach_diff XYZ-135" will try to attach diff to https://jira.<project_name>.com/browse/XYZ-135
39+ # At instance, "fast_diff_v2.sh XYZ-135" will try to attach diff to https://jira.<project_name>.com/browse/XYZ-135
0 commit comments