Skip to content

store issues as a private issues branch #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ You use _git issue_ with the following sub-commands.
### Start an issue repository
* `git issue clone`: Clone the specified remote repository.
* `git issue init`: Create a new issues repository in the current directory.
The `-e` option uses an existing Git project repository.
The `-e` option uses an existing Git project repository and store issues as a private issues branch.
The `-r` option stores the issues in a new issues repository.

### Work with an issue
* `git issue new`: Create a new open issue (with optional `-s` summary and -c "provider user repo" for github/gitlab export).
Expand Down
3 changes: 2 additions & 1 deletion git-issue.1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ Clone the specified remote repository.
\fBgit issue init\fP
.RS 4
Create a new issues repository in the current directory.
The \fC-e\fP option uses an existing Git project repository.
The \fC-e\fP option uses an existing Git project repository and store issues as a private issues branch.
The \fC-r\fP option stores the issues in a new issues repository.

.RE
.PP
Expand Down
41 changes: 34 additions & 7 deletions git-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# User agent string
# shellcheck disable=SC2034
# SC2034 : USER_AGENT appears unused. Verify use (or export if used externally)
USER_AGENT=https://github.com/dspinellis/git-issue/tree/afda065
USER_AGENT=https://github.com/dspinellis/git-issue/tree/4d2bc41

# Determine our script library path
my_IFS=$IFS
Expand Down Expand Up @@ -214,21 +214,25 @@ pager()
usage_init()
{
cat <<\USAGE_new_EOF
gi init usage: git issue init [-e]
-e Use existing project's Git repository
gi init usage: git issue init [-e] [-r]
-e Use existing project's Git repository
-r Store issues in a new issues repository
USAGE_new_EOF
exit 2
}

sub_init()
{
local existing username useremail
local existing username useremail issuesrepository currentbranch

while getopts e flag ; do
while getopts er flag ; do
case $flag in
e)
existing=1
;;
r)
issuesrepository=1
;;
?)
usage_init
;;
Expand All @@ -243,6 +247,19 @@ sub_init()
cdissues
if ! [ "$existing" ] ; then
git init -q || error 'Unable to initialize Git directory'
else
currentbranch=$(git symbolic-ref --short HEAD) || error 'you are not in a existing git repository'
fi
if ! [ "$issuesrepository" ] && [ "$existing" ] ; then
cd ..
cat >.git-issues-init.txt <<\EOF
Initialized by git-issue
EOF
git add .git-issues-init.txt
git commit -q -m "init git-issue"
git checkout -q --orphan issues
git rm -rfq .
cdissues
fi

# Editing templates
Expand Down Expand Up @@ -281,8 +298,18 @@ EOF
if [ -n "$useremail" ] ; then
git config --local user.email "$useremail"
fi
commit 'gi: Initialize issues repository' 'gi init'
echo "Initialized empty issues repository in $(pwd)"
if ! [ "$issuesrepository" ] && [ "$existing" ] ; then
cd ..
git mv .issues/* .
cdissues
commit 'gi: Created private issues branch' 'gi init'
git switch -q $currentbranch
git worktree add -q ../.issues issues
echo "Created private issues branch in $(pwd)"
else
commit 'gi: Initialize issues repository' 'gi init'
echo "Initialized empty issues repository in $(pwd)"
fi
}

# new: Open a new issue {{{1
Expand Down