Skip to content

Commit 21e33f7

Browse files
committed
Merge branch 'master' of github.com:dspinellis/git-issue
2 parents b4c07a3 + bfb07bc commit 21e33f7

File tree

5 files changed

+87
-72
lines changed

5 files changed

+87
-72
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ sync-docs:
2121
./sync-docs.sh
2222

2323
test:
24-
shellcheck --version >/dev/null 2>&1 && \
25-
shellcheck -x *.sh lib/git-issue/*.sh || \
26-
echo 'Skipping shellcheck; consider installing it'
24+
if shellcheck --version >/dev/null 2>&1 ; then \
25+
shellcheck -x *.sh lib/git-issue/*.sh ; \
26+
else \
27+
echo 'Skipping shellcheck; consider installing it' ; \
28+
fi
2729
./test.sh
2830

2931
uninstall:

git-issue.1

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.TH GIT-ISSUE 1 "11 October 2019"
1+
.TH GIT-ISSUE 1 "31 January 2020"
22
.\"
3-
.\" (C) Copyright 2016-2018 Diomidis Spinellis
3+
.\" (C) Copyright 2016-2020 Diomidis Spinellis
44
.\"
55
.\" This file is part of git-issue, the Git-based issue management system.
66
.\"
@@ -172,7 +172,7 @@ Run \fCcommand\fP in every issue directory. The following environment variables
172172

173173
The command can read, add/remove or edit any of the issue's attributes.
174174
Some potentially useful scripts to be used with this command are in the scripts/ directory.
175-
Remember to inspect the results (e.g \fCgi git diff\fP) and commit them with \fCgi git commit -a\fP.
175+
Remember to inspect the results (e.g. \fCgi git diff\fP) and commit them with \fCgi git commit -a\fP.
176176

177177
.RE
178178
.PP
@@ -203,15 +203,15 @@ Import/update GitHub/GitLab issues from the specified project.
203203
.RS 4
204204
Create the issue in the provided GitHub repository.
205205
With the \fC-e\fP option any escape sequences for the attributes present in the description, will be replaced as above.
206-
This can be used to e.g export an unsupported attribute to GitHub as text.
206+
This can be used to e.g. export an unsupported attribute to GitHub as text.
207207
.RE
208208
.PP
209209
\fBgit issue export\fP
210210
.RS 4
211211
Export issues for the specified project.
212212
Only the issues that have been imported and modified (or created by \fCgit issue create\fP) by \fCgit-issue\fP will be exported.
213213
With the \fC-e\fP option any escape sequences for the attributes present in the description, will be replaced as above.
214-
This can be used to e.g export an unsupported attribute to GitHub as text.
214+
This can be used to e.g. export an unsupported attribute to GitHub as text.
215215
.RE
216216
.PP
217217
\fBgit issue exportall\fP
@@ -644,14 +644,14 @@ Export modified issues back to GitHub
644644
.ft C
645645
.nf
646646
$ git issue export github dspinellis git-issue-test-issues # Needs a token with the relevant permissions
647-
Issue b83d92872dc16440402516a5f4ce1b8cc6436344 hasn't been modified, skipping...
648-
Comment a93764f32179e93493ceb0a7060efce1e980aff1 hasn't been modified, skipping...
647+
Issue b83d92872dc16440402516a5f4ce1b8cc6436344 not modified, skipping...
648+
Comment a93764f32179e93493ceb0a7060efce1e980aff1 not modified, skipping...
649649
Exporting issue 9179d381135273220301f175c03b101b3e9c703d as #15
650-
Issue 3651dd38e4e1d9dbce66649710324235c773fe78 hasn't been modified, skipping...
650+
Issue 3651dd38e4e1d9dbce66649710324235c773fe78 not modified, skipping...
651651
Updating comment d72c68d0177b500a91ea37548e6594f84457fd5b...
652-
Comment 6966d4d718c80cf8635e9276d6f391de70c22f93 hasn't been modified, skipping...
653-
Comment 85293a6904d0fbd6238fbb2e1c36fc65af9ffc60 hasn't been modified, skipping...
654-
Comment aea83723c0414ff135afcfb5165d64f8a7ad687c hasn't been modified, skipping...
652+
Comment 6966d4d718c80cf8635e9276d6f391de70c22f93 not modified, skipping...
653+
Comment 85293a6904d0fbd6238fbb2e1c36fc65af9ffc60 not modified, skipping...
654+
Comment aea83723c0414ff135afcfb5165d64f8a7ad687c not modified, skipping...
655655

656656
.fi
657657
.ft R
@@ -679,7 +679,9 @@ e6a95c9 - New issue entered from the command line
679679
<\fIhttps://github\.com/dspinellis/git\-issue\fR>
680680

681681
.SH AUTHOR
682-
Written by Diomidis Spinellis <\fIdds@aueb\.gr\fP>
682+
First version written by Diomidis Spinellis <\fIdds@aueb\.gr\fP>.
683+
Vuron Drosos <\fIvyrondrosos@gmail.com\fP> implemented the GitHub/GitLab
684+
export functionality during the Google Summer of Code 2019.
683685

684686
.SH BUGS
685687
Report bugs through

git-issue.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Rationale: Local makes for better code and works on many modern shells
77
# - SC1117: Backslash is literal. Prefer explicit escaping.
88
#
9-
# (C) Copyright 2016-2019 Diomidis Spinellis
9+
# (C) Copyright 2016-2020 Diomidis Spinellis
1010
#
1111
# This file is part of git-issue, the Git-based issue management system.
1212
#
@@ -33,16 +33,21 @@ USER_AGENT=https://github.com/dspinellis/git-issue/tree/ea66152
3333
my_IFS=$IFS
3434
IFS=:
3535

36+
# Set library path
3637
# shellcheck disable=SC2086
3738
# Rationale: Word splitting not an issue
38-
LD_LIBRARY_PATH="$(dirname $0)/lib:$LD_LIBRARY_PATH:/usr/lib:/usr/local/lib"
39-
for i in ${LD_LIBRARY_PATH} ; do
39+
LIB_PATH="$(dirname $0)/../lib:$LD_LIBRARY_PATH:/usr/lib:/usr/local/lib"
40+
if [ "x$GIT_ISSUE_LIB_PATH" != x ] ; then
41+
LIB_PATH="$GIT_ISSUE_LIB_PATH"
42+
fi
43+
for i in ${LIB_PATH} ; do
4044
if [ -d "${i}/git-issue" ] ; then
4145
MY_LIB="${i}/git-issue"
4246
break
4347
fi
4448
done
4549

50+
4651
IFS=$my_IFS
4752

4853
if command -v gdate > /dev/null ; then
@@ -59,6 +64,9 @@ error()
5964
}
6065

6166
$DATEBIN --help | grep 'gnu' > /dev/null || error "Require GNU date"
67+
68+
test "x$MY_LIB" != x || error "No git-issue directory in path $LIB_PATH"
69+
6270
# Return a unique identifier for the specified file
6371
filesysid()
6472
{
@@ -163,7 +171,8 @@ commit()
163171
shift
164172
commit_message=$1
165173
shift
166-
git commit --allow-empty -q -m "$commit_summary
174+
GIT_AUTHOR_DATE="$GIT_EVENT_DATE" GIT_COMMITTER_DATE="$GIT_EVENT_DATE" \
175+
git commit --allow-empty -q -m "$commit_summary
167176
168177
$commit_message" "$@" || trans_abort
169178
}
@@ -1398,8 +1407,8 @@ Synchronize with remote repositories
13981407
pull Update local Git repository with remote changes
13991408
import Import/update GitHub/GitLab issues from the specified project
14001409
create Create the issue in the provided GitHub repository
1401-
export Export issues for the specified project
1402-
exportall Export all open issues in the database (-a to include closed ones) to GitHub/GitLab Useful for cloning whole repositories
1410+
export Export modified issues for the specified project
1411+
exportall Export all open issues in the database (-a to include closed ones) to GitHub/GitLab. Useful for cloning whole repositories
14031412
14041413
Help and debug
14051414
help Display help information about git issue

lib/git-issue/import-export.sh

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ usage_export()
1717
{
1818
cat <<\USAGE_export_EOF
1919
gi export usage: git issue export provider user repo
20-
-e Expand escape attribute sequences before exporting(see gi list -l)
20+
-e Expand escape attribute sequences before exporting (see gi list -l)
2121
2222
Example: git issue export github torvalds linux
2323
USAGE_export_EOF
@@ -157,7 +157,7 @@ usage_create_issue()
157157
{
158158
cat <<\USAGE_create_issue_EOF
159159
gi create usage: git issue create id provider user repo
160-
-e Expand escape attribute sequences before exporting(see gi list -l)
160+
-e Expand escape attribute sequences before exporting (see gi list -l)
161161
-n Keep HTTP transaction files
162162
-u num Update issue #num instead of creating a new one
163163
@@ -577,7 +577,7 @@ import_comments()
577577
csha=$(cat "$import_dir/$comment_id")
578578
else
579579
name=$(jq -r ".[$i].$juser" comments-body)
580-
GIT_AUTHOR_DATE=$(jq -r ".[$i].updated_at" comments-body) \
580+
GIT_EVENT_DATE=$(jq -r ".[$i].updated_at" comments-body) \
581581
commit 'gi: Add comment' "gi comment mark $isha" \
582582
--author="$name <$name@users.noreply.$provider.com>"
583583
csha=$(git rev-parse HEAD)
@@ -602,12 +602,12 @@ import_comments()
602602
name=$(jq -r ".[$i].$juser" comments-body)
603603
if [ "$provider" = github ] ; then
604604
html_url=$(jq -r ".[$i].html_url" comments-body)
605-
GIT_AUTHOR_DATE=$(jq -r ".[$i].updated_at" comments-body) \
605+
GIT_EVENT_DATE=$(jq -r ".[$i].updated_at" comments-body) \
606606
commit 'gi: Import comment message' "gi comment message $isha $csha
607607
Comment URL: $html_url" \
608608
--author="$name <$name@users.noreply.github.com>"
609609
else
610-
GIT_AUTHOR_DATE=$(jq -r ".[$i].updated_at" comments-body) \
610+
GIT_EVENT_DATE=$(jq -r ".[$i].updated_at" comments-body) \
611611
commit 'gi: Import comment message' "gi comment message $isha $csha"\
612612
--author="$name <$name@users.noreply.gitlab.com>"
613613
fi
@@ -665,7 +665,7 @@ import_issues()
665665
sha=$(cat "$import_dir/sha")
666666
else
667667
name=$(jq -r ".[$i].$juser" issue-body)
668-
GIT_AUTHOR_DATE=$(jq -r ".[$i].updated_at" issue-body) \
668+
GIT_EVENT_DATE=$(jq -r ".[$i].updated_at" issue-body) \
669669
commit 'gi: Add issue' 'gi new mark' \
670670
--author="$name <$name@users.noreply.$provider.com>"
671671
sha=$(git rev-parse HEAD)
@@ -776,7 +776,7 @@ import_issues()
776776
git add "$path/description" "$path/tags" imports || trans_abort
777777
if ! git diff --quiet HEAD ; then
778778
name=${name:-$(jq -r ".[$i].$juser" issue-body)}
779-
GIT_AUTHOR_DATE=$(jq -r ".[$i].updated_at" issue-body) \
779+
GIT_EVENT_DATE=$(jq -r ".[$i].updated_at" issue-body) \
780780
commit "gi: Import issue #$issue_number from $provider/$user/$repo" \
781781
"Issue URL: https://$provider.com/$user/$repo/issues/$issue_number" \
782782
--author="$name <$name@users.noreply.$provider.com>"
@@ -829,7 +829,7 @@ export_issues()
829829

830830
rm -f create-body create-header
831831
else
832-
echo "Issue $sha hasn't been modified, skipping..."
832+
echo "Issue $sha not modified, skipping..."
833833
fi
834834

835835
# Comments
@@ -850,7 +850,7 @@ export_issues()
850850
if [ -n "$(git rev-list "$lastimport"..HEAD "$path/comments/$csha")" ] || [ -z "$cfound" ] ; then
851851
create_comment "$csha" "$provider" "$user" "$repo" "$num"
852852
else
853-
echo "Comment $csha hasn't been modified, skipping..."
853+
echo "Comment $csha not modified, skipping..."
854854
fi
855855
done
856856
fi
@@ -933,7 +933,7 @@ sub_import()
933933
usage_exportall()
934934
{
935935
cat <<\USAGE_exportall_EOF
936-
gi new usage: git issue list [-a] provider user repo
936+
gi new usage: git issue exportall [-a] provider user repo
937937
USAGE_exportall_EOF
938938
exit 2
939939
}
@@ -951,49 +951,47 @@ sub_exportall()
951951
usage_exportall
952952
;;
953953
esac
954-
done
955-
shift $((OPTIND - 1));
956-
957-
test "$1" = github -o "$1" = gitlab || usage_exportall
958-
test -n "$2" -a -n "$3" || usage_exportall
959-
provider="$1"
960-
user="$2"
961-
repo="$3"
954+
done
955+
shift $((OPTIND - 1));
962956

963-
# Create list of relevant shas sorted by date
964-
shas=$(sub_list -l %i -o %c "$all"| sed '/^$/d' | tr '\n' ' ')
957+
test "$1" = github -o "$1" = gitlab || usage_exportall
958+
test -n "$2" -a -n "$3" || usage_exportall
959+
provider="$1"
960+
user="$2"
961+
repo="$3"
965962

966-
cdissues
963+
# Create list of relevant shas sorted by date
964+
shas=$(sub_list -l %i -o %c "$all"| sed '/^$/d' | tr '\n' ' ')
967965

968-
# Remove already exported issues
969-
if [ -d "imports/$provider/$user/$repo" ] ; then
970-
for i in "imports/$provider/$user/$repo/"[0-9]* ; do
971-
shas=$(echo "$shas" | sed "s/$(head -c 7 "$i/sha")//")
972-
done
973-
fi
966+
cdissues
974967

975-
for i in $shas ; do
976-
echo "Creating issue $i..."
977-
create_issue -n "$i" "$provider" "$user" "$repo"
978-
# get created issue id
979-
if [ "$provider" = github ] ; then
980-
num=$(jq '.number' create-body)
981-
else
982-
num=$(jq '.iid' create-body)
983-
fi
984-
rm -f create-header create-body
985-
986-
# Create comments
987-
988-
path=$(issue_path_part "$i") || exit
989-
if [ -d "$path/comments" ] ; then
990-
local csha cfound
991-
git rev-list --reverse --grep="^gi comment mark $i" HEAD |
992-
while read -r csha ; do
993-
create_comment "$csha" "$provider" "$user" "$repo" "$num"
994-
done
968+
# Remove already exported issues
969+
if [ -d "imports/$provider/$user/$repo" ] ; then
970+
for i in "imports/$provider/$user/$repo/"[0-9]* ; do
971+
shas=$(echo "$shas" | sed "s/$(head -c 7 "$i/sha")//")
972+
done
995973
fi
996-
997-
done
998974

975+
for i in $shas ; do
976+
echo "Creating issue $i..."
977+
create_issue -n "$i" "$provider" "$user" "$repo"
978+
# get created issue id
979+
if [ "$provider" = github ] ; then
980+
num=$(jq '.number' create-body)
981+
else
982+
num=$(jq '.iid' create-body)
983+
fi
984+
rm -f create-header create-body
985+
986+
# Create comments
987+
988+
path=$(issue_path_part "$i") || exit
989+
if [ -d "$path/comments" ] ; then
990+
local csha cfound
991+
git rev-list --reverse --grep="^gi comment mark $i" HEAD |
992+
while read -r csha ; do
993+
create_comment "$csha" "$provider" "$user" "$repo" "$num"
994+
done
995+
fi
996+
done
999997
}

test.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Rationale: We run this after creating the directory
1111
#
1212
#
13-
# (C) Copyright 2016 Diomidis Spinellis
13+
# (C) Copyright 2016-2020 Diomidis Spinellis
1414
#
1515
# This file is part of gi, the Git-based issue management system.
1616
#
@@ -180,6 +180,10 @@ ntest=0
180180
gi=$(pwd)/git-issue.sh
181181
gi_re=$(echo "$gi" | sed 's/[^0-9A-Za-z]/\\&/g')
182182

183+
# Setup GIT_ISSUE_LIB_PATH to allow pulling import-export.sh from lib
184+
GIT_ISSUE_LIB_PATH="$(pwd)/lib"
185+
export GIT_ISSUE_LIB_PATH
186+
183187
start sync-docs
184188
GenFiles="git-issue.sh git-issue.1"
185189
if ! git diff --quiet HEAD ; then
@@ -487,7 +491,7 @@ else
487491
try "$gi" new -c "github $ghrepo" -s "Issue exported directly"
488492
"$gi" assign "$issue2" "$ghuser" > /dev/null 2>&1
489493
try "$gi" export github $ghrepo
490-
start ; "$gi" export github $ghrepo | try_grep "Issue $issue.* hasn't been modified, skipping..."
494+
start ; "$gi" export github $ghrepo | try_grep "Issue $issue.* not modified, skipping..."
491495
# Test invalid assignee
492496
"$gi" assign "$issue2" octocat > /dev/null 2>&1
493497
start ; "$gi" export github $ghrepo | try_grep "Couldn't add assignee octocat. Skipping..."

0 commit comments

Comments
 (0)