Skip to content
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 bin/git-issue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/sh
#!/bin/bash
#
# git-issue - Distributed issue tracking embedded in Git
#
# Usage: git issue <command> [<args>]
#

set -e
set -o pipefail

VERSION="1.3.3"

Expand Down
3 changes: 2 additions & 1 deletion bin/git-issue-comment
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/sh
#!/bin/bash
#
# git-issue-comment - Add a comment to an issue
#

set -e
set -o pipefail

. "$(dirname "$0")/git-issue-lib"

Expand Down
3 changes: 2 additions & 1 deletion bin/git-issue-create
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/sh
#!/bin/bash
#
# git-issue-create - Create a new issue
#

set -e
set -o pipefail

. "$(dirname "$0")/git-issue-lib"

Expand Down
7 changes: 4 additions & 3 deletions bin/git-issue-edit
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/sh
#!/bin/bash
#
# git-issue-edit - Edit metadata of an existing issue
#

set -e
set -o pipefail

. "$(dirname "$0")/git-issue-lib"

Expand Down Expand Up @@ -213,8 +214,8 @@ issue_head="$(git rev-parse "$issue_ref")"
if test -n "$add_labels" || test -n "$remove_labels"
then
# Get current labels
current_labels="$(git log --format='%(trailers:key=Labels,valueonly)' "$issue_ref" | \
sed '/^$/d' | head -1)"
current_labels="$(git log -1 --format='%(trailers:key=Labels,valueonly)' "$issue_ref" | \
sed '/^$/d')"
current_labels="$(printf '%s' "$current_labels" | sed 's/^[[:space:]]*//')"

final_labels="$current_labels"
Expand Down
3 changes: 2 additions & 1 deletion bin/git-issue-export
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/sh
#!/bin/bash
#
# git-issue-export - Export local issues to an external provider
#

set -e
set -o pipefail

usage() {
cat <<EOF
Expand Down
15 changes: 8 additions & 7 deletions bin/git-issue-export-gitea
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# git-issue-export-gitea - Export issues to Gitea/Forgejo
#
Expand All @@ -7,6 +7,7 @@
#

set -e
set -o pipefail

usage() {
cat <<EOF
Expand Down Expand Up @@ -358,24 +359,24 @@ do
n_keep=$((n_body - n_trailers - 1))
if test "$n_keep" -gt 0
then
body="$(printf '%s\n' "$raw_body" | head -n "$n_keep")"
body="$(set +o pipefail; printf '%s\n' "$raw_body" | head -n "$n_keep")"
fi
else
body="$raw_body"
fi
fi

# Get current state
state="$(git log --format='%(trailers:key=State,valueonly)' "$ref" | sed '/^$/d' | head -1)"
state="$(git log -1 --format='%(trailers:key=State,valueonly)' "$ref" | sed '/^$/d')"
state="$(printf '%s' "$state" | sed 's/^[[:space:]]*//')"

# Get labels
labels="$(git log --format='%(trailers:key=Labels,valueonly)' "$ref" | sed '/^$/d' | head -1)"
labels="$(git log -1 --format='%(trailers:key=Labels,valueonly)' "$ref" | sed '/^$/d')"
labels="$(printf '%s' "$labels" | sed 's/^[[:space:]]*//')"

# Get assignee (canonical email)
# Use full trailer format to distinguish "no trailer" from "empty value"
_assignee_line="$(git log --format='%(trailers:key=Assignee)' "$ref" | sed '/^$/d' | head -1)"
_assignee_line="$(git log -1 --format='%(trailers:key=Assignee)' "$ref" | sed '/^$/d')"
has_assignee=0
assignee_email=""
if test -n "$_assignee_line"
Expand All @@ -386,7 +387,7 @@ do

# Check for Provider-ID in commit chain
existing_pid=""
existing_pid="$(git log --format='%(trailers:key=Provider-ID,valueonly)' "$ref" | \
existing_pid="$(set +o pipefail; git log --format='%(trailers:key=Provider-ID,valueonly)' "$ref" | \
sed '/^$/d' | sed 's/^[[:space:]]*//' | head -1)"

if test -n "$existing_pid"
Expand Down Expand Up @@ -458,7 +459,7 @@ do
n_keep=$((n_body - n_trailers - 1))
if test "$n_keep" -gt 0
then
cmt_body="$(printf '%s\n' "$cmt_body_full" | head -n "$n_keep")"
cmt_body="$(set +o pipefail; printf '%s\n' "$cmt_body_full" | head -n "$n_keep")"
fi
else
cmt_body="$cmt_body_full"
Expand Down
15 changes: 8 additions & 7 deletions bin/git-issue-export-github
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/sh
#!/bin/bash
#
# git-issue-export-github - Export issues to GitHub
#
# Usage: git issue export github:<owner>/<repo> [options]
#

set -e
set -o pipefail

usage() {
cat <<EOF
Expand Down Expand Up @@ -254,24 +255,24 @@ do
n_keep=$((n_body - n_trailers - 1))
if test "$n_keep" -gt 0
then
body="$(printf '%s\n' "$raw_body" | head -n "$n_keep")"
body="$(set +o pipefail; printf '%s\n' "$raw_body" | head -n "$n_keep")"
fi
else
body="$raw_body"
fi
fi

# Get current state
state="$(git log --format='%(trailers:key=State,valueonly)' "$ref" | sed '/^$/d' | head -1)"
state="$(set +o pipefail; git log --format='%(trailers:key=State,valueonly)' "$ref" | sed '/^$/d' | head -1)"
state="$(printf '%s' "$state" | sed 's/^[[:space:]]*//')"

# Get labels
labels="$(git log --format='%(trailers:key=Labels,valueonly)' "$ref" | sed '/^$/d' | head -1)"
labels="$(set +o pipefail; git log --format='%(trailers:key=Labels,valueonly)' "$ref" | sed '/^$/d' | head -1)"
labels="$(printf '%s' "$labels" | sed 's/^[[:space:]]*//')"

# Get assignee (canonical email)
# Use full trailer format to distinguish "no trailer" from "empty value"
_assignee_line="$(git log --format='%(trailers:key=Assignee)' "$ref" | sed '/^$/d' | head -1)"
_assignee_line="$(set +o pipefail; git log --format='%(trailers:key=Assignee)' "$ref" | sed '/^$/d' | head -1)"
has_assignee=0
assignee_email=""
if test -n "$_assignee_line"
Expand All @@ -282,7 +283,7 @@ do

# Check for Provider-ID in any commit in the chain
existing_pid=""
existing_pid="$(git log --format='%(trailers:key=Provider-ID,valueonly)' "$ref" | \
existing_pid="$(set +o pipefail; git log --format='%(trailers:key=Provider-ID,valueonly)' "$ref" | \
sed '/^$/d' | sed 's/^[[:space:]]*//' | head -1)"

if test -n "$existing_pid"
Expand Down Expand Up @@ -357,7 +358,7 @@ do
n_keep=$((n_body - n_trailers - 1))
if test "$n_keep" -gt 0
then
cmt_body="$(printf '%s\n' "$cmt_body_full" | head -n "$n_keep")"
cmt_body="$(set +o pipefail; printf '%s\n' "$cmt_body_full" | head -n "$n_keep")"
fi
else
cmt_body="$cmt_body_full"
Expand Down
15 changes: 8 additions & 7 deletions bin/git-issue-export-gitlab
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/sh
#!/bin/bash
#
# git-issue-export-gitlab - Export issues to GitLab
#
# Usage: git issue export gitlab:<group>/<project> [options]
#

set -e
set -o pipefail

usage() {
cat <<EOF
Expand Down Expand Up @@ -225,24 +226,24 @@ do
n_keep=$((n_body - n_trailers - 1))
if test "$n_keep" -gt 0
then
body="$(printf '%s\n' "$raw_body" | head -n "$n_keep")"
body="$(set +o pipefail; printf '%s\n' "$raw_body" | head -n "$n_keep")"
fi
else
body="$raw_body"
fi
fi

# Get current state
state="$(git log --format='%(trailers:key=State,valueonly)' "$ref" | sed '/^$/d' | head -1)"
state="$(set +o pipefail; git log --format='%(trailers:key=State,valueonly)' "$ref" | sed '/^$/d' | head -1)"
state="$(printf '%s' "$state" | sed 's/^[[:space:]]*//')"

# Get labels
labels="$(git log --format='%(trailers:key=Labels,valueonly)' "$ref" | sed '/^$/d' | head -1)"
labels="$(set +o pipefail; git log --format='%(trailers:key=Labels,valueonly)' "$ref" | sed '/^$/d' | head -1)"
labels="$(printf '%s' "$labels" | sed 's/^[[:space:]]*//')"

# Get assignee (canonical email)
# Use full trailer format to distinguish "no trailer" from "empty value"
_assignee_line="$(git log --format='%(trailers:key=Assignee)' "$ref" | sed '/^$/d' | head -1)"
_assignee_line="$(set +o pipefail; git log --format='%(trailers:key=Assignee)' "$ref" | sed '/^$/d' | head -1)"
has_assignee=0
assignee_email=""
if test -n "$_assignee_line"
Expand All @@ -253,7 +254,7 @@ do

# Check for Provider-ID in commit chain
existing_pid=""
existing_pid="$(git log --format='%(trailers:key=Provider-ID,valueonly)' "$ref" | \
existing_pid="$(set +o pipefail; git log --format='%(trailers:key=Provider-ID,valueonly)' "$ref" | \
sed '/^$/d' | sed 's/^[[:space:]]*//' | head -1)"

if test -n "$existing_pid"
Expand Down Expand Up @@ -325,7 +326,7 @@ do
n_keep=$((n_body - n_trailers - 1))
if test "$n_keep" -gt 0
then
cmt_body="$(printf '%s\n' "$cmt_body_full" | head -n "$n_keep")"
cmt_body="$(set +o pipefail; printf '%s\n' "$cmt_body_full" | head -n "$n_keep")"
fi
else
cmt_body="$cmt_body_full"
Expand Down
3 changes: 2 additions & 1 deletion bin/git-issue-fsck
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# git-issue-fsck - Validate issue data integrity
#
Expand All @@ -7,6 +7,7 @@
#

set -e
set -o pipefail

. "$(dirname "$0")/git-issue-lib"

Expand Down
3 changes: 2 additions & 1 deletion bin/git-issue-import
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/sh
#!/bin/bash
#
# git-issue-import - Import issues from an external provider
#

set -e
set -o pipefail

usage() {
cat <<EOF
Expand Down
13 changes: 7 additions & 6 deletions bin/git-issue-import-gitea
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# git-issue-import-gitea - Import issues from Gitea/Forgejo
#
Expand All @@ -7,6 +7,7 @@
#

set -e
set -o pipefail

usage() {
cat <<EOF
Expand Down Expand Up @@ -421,8 +422,8 @@ do

# Resolve comment author to name and email via API (also populates cache)
_comment_info="$(resolve_gitea_user "$comment_author_username")"
comment_author_name="$(printf '%s' "$_comment_info" | head -1)"
comment_email="$(printf '%s' "$_comment_info" | tail -1)"
comment_author_name="$(printf '%s\n' "${_comment_info%%$'\n'*}")"
comment_email="$(set +o pipefail; printf '%s' "$_comment_info" | tail -1)"

if test "$dry_run" -eq 1
then
Expand Down Expand Up @@ -474,8 +475,8 @@ do

# Resolve author to name and email via API (also populates cache)
_author_info="$(resolve_gitea_user "$author_username")"
author_name="$(printf '%s' "$_author_info" | head -1)"
author_email="$(printf '%s' "$_author_info" | tail -1)"
author_name="$(printf '%s\n' "${_author_info%%$'\n'*}")"
author_email="$(set +o pipefail; printf '%s' "$_author_info" | tail -1)"

# Map state to our format
case "$state" in
Expand All @@ -493,7 +494,7 @@ do
if test -n "$assignee_login"
then
_assignee_info="$(resolve_gitea_user "$assignee_login")"
assignee_email="$(printf '%s' "$_assignee_info" | tail -1)"
assignee_email="$(set +o pipefail; printf '%s' "$_assignee_info" | tail -1)"
fi

if test "$dry_run" -eq 1
Expand Down
21 changes: 11 additions & 10 deletions bin/git-issue-import-github
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/sh
#!/bin/bash
#
# git-issue-import-github - Import issues from GitHub
#
# Usage: git issue import github:<owner>/<repo> [options]
#

set -e
set -o pipefail

usage() {
cat <<EOF
Expand Down Expand Up @@ -272,11 +273,11 @@ do
comment_login="$(printf '%s' "$comments_json" | jq -r ".[$i].user.login")"

comment_info="$(resolve_user "$comment_login")"
comment_name="$(printf '%s' "$comment_info" | head -1)"
comment_email="$(printf '%s' "$comment_info" | tail -1)"
comment_name="$(printf '%s\n' "${comment_info%%$'\n'*}")"
comment_email="$(set +o pipefail; printf '%s' "$comment_info" | tail -1)"

# Split comment into subject and body
first_line="$(printf '%s\n' "$comment_body" | head -1)"
first_line="$(printf '%s\n' "${comment_body%%$'\n'*}")"
remaining="$(printf '%s\n' "$comment_body" | tail -n +2)"

if test ${#first_line} -gt 72
Expand Down Expand Up @@ -356,8 +357,8 @@ do

# Resolve author
author_info="$(resolve_user "$author_login")"
author_name="$(printf '%s' "$author_info" | head -1)"
author_email="$(printf '%s' "$author_info" | tail -1)"
author_name="$(printf '%s\n' "${author_info%%$'\n'*}")"
author_email="$(set +o pipefail; printf '%s' "$author_info" | tail -1)"

# Generate UUID
if command -v uuidgen >/dev/null 2>&1
Expand Down Expand Up @@ -395,7 +396,7 @@ $body"
if test -n "$assignee_login"
then
assignee_info="$(resolve_user "$assignee_login")"
assignee_email="$(printf '%s' "$assignee_info" | tail -1)"
assignee_email="$(set +o pipefail; printf '%s' "$assignee_info" | tail -1)"
git interpret-trailers --in-place --trailer "Assignee: $assignee_email" "$tmpfile"
fi

Expand Down Expand Up @@ -430,11 +431,11 @@ $body"
comment_login="$(printf '%s' "$comments_json" | jq -r ".[$i].user.login")"

comment_info="$(resolve_user "$comment_login")"
comment_name="$(printf '%s' "$comment_info" | head -1)"
comment_email="$(printf '%s' "$comment_info" | tail -1)"
comment_name="$(printf '%s\n' "${comment_info%%$'\n'*}")"
comment_email="$(set +o pipefail; printf '%s' "$comment_info" | tail -1)"

# Split comment into subject (max 72 chars) and body
first_line="$(printf '%s\n' "$comment_body" | head -1)"
first_line="$(printf '%s\n' "${comment_body%%$'\n'*}")"
remaining="$(printf '%s\n' "$comment_body" | tail -n +2)"

if test ${#first_line} -gt 72
Expand Down
Loading