-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjira2phab.sh
78 lines (74 loc) · 2.49 KB
/
jira2phab.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##
## JIRA to Phabricator migration script
##
## Copyright (C) 2014 met.no
##
## Contact information:
## Norwegian Meteorological Institute
## Box 43 Blindern
## 0313 OSLO
## NORWAY
## E-mail: @met.no
##
## This is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#!/bin/bash
CERT="ENTER-CONDUIT-CERTIFICATE"
PHAB="ENTER-PHAB-URL"
USER="ENTER-USER-NAME"
PROJ="ENTER-PROJECT-NAME"
lbls="BORA Requirements: "
read_dom () {
local IFS=\>
read -d \< ENTITY CONTENT
local ret=$?
TAG_NAME=${ENTITY%% *}
ATTRIBUTES=${ENTITY#* }
return $ret
}
parse_dom () {
if [[ $TAG_NAME = "title" ]] ; then
eval local $ATTRIBUTES
#echo "Title: $CONTENT"
TID=`arcyon task-create --uri $PHAB --user $USER --cert $CERT --projects "$PROJ" --format-id "$CONTENT"`
echo $TID
elif [[ $TAG_NAME = "description" ]] ; then
eval local $ATTRIBUTES
desc=$(echo $CONTENT | sed 's/<br\/>/\\n/g' | sed 's/<\/p>/\\n\\n/g' | sed 's/<p>//g' )
elif [[ $TAG_NAME = "customfieldname" ]] ; then
# This is used to grab a custom field Requirement
eval local $ATTRIBUTES
if [[ $CONTENT = "Requirement" ]] ; then
REQ="req"
fi
elif [[ $TAG_NAME = "label" ]] ; then
eval local $ATTRIBUTES
if [[ $REQ = "req" ]] ; then
lbls="$lbls $CONTENT,"
fi
elif [[ $TAG_NAME = "/customfieldvalues" ]] ; then
REQ="false"
elif [[ $TAG_NAME = "comment" ]] ; then
eval local $ATTRIBUTES
ENTRY="On $created, @$author wrote:\n\n$CONTENT"
com=$(echo $ENTRY | sed 's/<br\/>/\\n/g' | sed 's/<\/p>/\\n\\n/g' | sed 's/<p>//g' | sed 's/<[^>]\+">//g' | sed 's/<\/a>//g' | sed 's/'/\"/g' )
#echo -e $com
arcyon task-update --uri $PHAB --user $USER --cert $CERT $TID --comment "$(echo -e $com)"
elif [[ $TAG_NAME = "/item" ]] ; then
if [[ $lbls != "BORA Requirements: " ]] ; then
desc=$(echo "$desc$lbls" | sed 's/,\+$//' )
fi
#echo -e "Description:\n$desc"
#Reset requirements string at the end of the description
lbls="BORA Requirements: "
arcyon task-update --uri $PHAB --user $USER --cert $CERT $TID --description "$(echo -e $desc)"
fi
}
while read_dom; do
parse_dom
done