Skip to content
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

WIP Add accountability to issue edits #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
63 changes: 63 additions & 0 deletions git-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,66 @@ else
DATEBIN="date"
fi


##
## PLUGIN AREA
## (how to specify in different file when run from different location)
##

opt_archive=1
opt_sign=1

sig_by_state() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment describing what this function does. Consider also expanding sig.

if [ -z $opt_sign ]; then
return 0
fi

cdissues
path=$(issue_path_part $1 2> /dev/null)
if [ -z "$path" ]; then
return 1
fi

issue_hash=$1
state_hash=$2

# signature message is the signature of the TAR archive wrapping the three items, added in the sequence defined by archive_by_path
gpg_key=$(git config --get user.signingKey)
if [ -z "$gpg_key" ]; then
echo "no gpg key"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo 'No GPG key' 1>&2

return 1
fi
echo -n $h | gpg -a -b -u $gpg_key > $path/$state_hash.asc
}

archive_by_path() {
if [ -z $opt_archive ]; then
return 0
fi

cdissues
path=$(issue_path_part $1 2> /dev/null)
if [ -z "$path" ]; then
return 1
fi

t=$(mktemp -d)
now=$(date +%s)
echo -n $now > $t/timestamp
cp -v $path/description $t/description
cp -v $path/tags $t/tags
pushd $t
tar -zcvf a.tar.gz description tags timestamp
h=$(sha1sum a.tar.gz | awk '{ print $1; }')
popd
mv -v $t/a.tar.gz $path/${now}_${h}.tar.gz
sig_by_state $1 $h
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please eliminate the -v options to tar, cp, mv. By default the operation should be silent.

}

##
## END PLUGIN AREA
##

# Exit after displaying the specified error
error()
{
Expand Down Expand Up @@ -963,6 +1023,9 @@ sub_edit()

trans_start
edit "$path/description" || trans_abort

archive_by_path $1

git add "$path/description" || trans_abort
commit 'gi: Edit issue description' "gi edit description $isha"
echo "Edited issue $(short_sha "$isha")"
Expand Down