hive-forge: add attach-issue and attach-comment verbs (closes #206)
This commit is contained in:
parent
da8a711a60
commit
6ffee8e6f6
3 changed files with 43 additions and 13 deletions
|
|
@ -221,28 +221,56 @@ pkgs.writeShellApplication {
|
|||
| jq -r '.tree.sha // .sha'
|
||||
}
|
||||
|
||||
cmd_attach_issue() {
|
||||
# attach-issue <number> <file> [repo]
|
||||
# Upload a file as an attachment to an issue. Prints the download URL.
|
||||
if [ $# -lt 2 ]; then echo "usage: hive-forge attach-issue <number> <file> [repo]" >&2; exit 1; fi
|
||||
local _n="$1" _file="$2" _repo="''${3:-$HIVE_FORGE_REPO}"
|
||||
if [ ! -f "$_file" ]; then echo "hive-forge attach-issue: file not found: $_file" >&2; exit 1; fi
|
||||
${pkgs.curl}/bin/curl -sf -X POST \
|
||||
-H "Authorization: token $_token" \
|
||||
-F "attachment=@$_file" \
|
||||
"$FORGE_API/repos/$_repo/issues/$_n/assets" \
|
||||
| jq -r '.browser_download_url'
|
||||
}
|
||||
|
||||
cmd_attach_comment() {
|
||||
# attach-comment <comment-id> <file> [repo]
|
||||
# Upload a file as an attachment to an issue comment. Prints the download URL.
|
||||
if [ $# -lt 2 ]; then echo "usage: hive-forge attach-comment <comment-id> <file> [repo]" >&2; exit 1; fi
|
||||
local _id="$1" _file="$2" _repo="''${3:-$HIVE_FORGE_REPO}"
|
||||
if [ ! -f "$_file" ]; then echo "hive-forge attach-comment: file not found: $_file" >&2; exit 1; fi
|
||||
${pkgs.curl}/bin/curl -sf -X POST \
|
||||
-H "Authorization: token $_token" \
|
||||
-F "attachment=@$_file" \
|
||||
"$FORGE_API/repos/$_repo/issues/comments/$_id/assets" \
|
||||
| jq -r '.browser_download_url'
|
||||
}
|
||||
|
||||
VERB="''${1:-}"
|
||||
if [ -z "$VERB" ]; then
|
||||
echo "usage: hive-forge <verb> [args...]" >&2
|
||||
echo "verbs: view, issue, pr, comment, assign, close, labels, pr-reviews, branches, tree-sha" >&2
|
||||
echo "verbs: view, issue, pr, comment, assign, close, labels, pr-reviews, branches, tree-sha, attach-issue, attach-comment" >&2
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
|
||||
case "$VERB" in
|
||||
view) cmd_view "$@" ;;
|
||||
issue) cmd_issue "$@" ;;
|
||||
pr) cmd_pr "$@" ;;
|
||||
comment) cmd_comment "$@" ;;
|
||||
assign) cmd_assign "$@" ;;
|
||||
close) cmd_close "$@" ;;
|
||||
labels) cmd_labels "$@" ;;
|
||||
pr-reviews) cmd_pr_reviews "$@" ;;
|
||||
branches) cmd_branches "$@" ;;
|
||||
tree-sha) cmd_tree_sha "$@" ;;
|
||||
view) cmd_view "$@" ;;
|
||||
issue) cmd_issue "$@" ;;
|
||||
pr) cmd_pr "$@" ;;
|
||||
comment) cmd_comment "$@" ;;
|
||||
assign) cmd_assign "$@" ;;
|
||||
close) cmd_close "$@" ;;
|
||||
labels) cmd_labels "$@" ;;
|
||||
pr-reviews) cmd_pr_reviews "$@" ;;
|
||||
branches) cmd_branches "$@" ;;
|
||||
tree-sha) cmd_tree_sha "$@" ;;
|
||||
attach-issue) cmd_attach_issue "$@" ;;
|
||||
attach-comment) cmd_attach_comment "$@" ;;
|
||||
*)
|
||||
echo "hive-forge: unknown verb '$VERB'" >&2
|
||||
echo "verbs: view, issue, pr, comment, assign, close, labels, pr-reviews, branches, tree-sha" >&2
|
||||
echo "verbs: view, issue, pr, comment, assign, close, labels, pr-reviews, branches, tree-sha, attach-issue, attach-comment" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue