-
Notifications
You must be signed in to change notification settings - Fork 5
/
issues.sh
executable file
·64 lines (56 loc) · 1.72 KB
/
issues.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
source "base_api.sh"
source "utils.sh"
function list_issues() {
local -r TOKEN="$1"
local -r OWNER="$2"
local -r GITHUB_REPO="$3"
base_api::get "$TOKEN" "repos/$OWNER/$GITHUB_REPO/issues"
}
function count_issues() {
local -r TOKEN="$1"
local -r OWNER="$2"
local -r GITHUB_REPO="$3"
body=$(base_api::get "$TOKEN" "repos/$OWNER/$GITHUB_REPO/issues")
echo "$body" | jq 'map(select(.pull_request == null)) | length'
}
function get_unique_assignee() {
local -r TOKEN="$1"
local -r OWNER="$2"
local -r GITHUB_REPO="$3"
body=$(base_api::get "$TOKEN" "repos/$OWNER/$GITHUB_REPO/issues")
echo "$body" | jq -r '.[] | .assignee.login' | uniq -u
}
function add_issue_label() {
local -r TOKEN="$1"
local -r OWNER="$2"
local -r GITHUB_REPO="$3"
local -r ISSUE_NUM="$4"
local -r PAYLOAD="$5"
# payload should be: {"labels": ["label2", "label2"]}
base_api::post "$TOKEN" "repos/$OWNER/$GITHUB_REPO/issues/$ISSUE_NUM/labels" "$PAYLOAD"
}
function remove_issue_label() {
local -r TOKEN="$1"
local -r OWNER="$2"
local -r GITHUB_REPO="$3"
local -r ISSUE_NUM="$4"
local -r PAYLOAD="$5"
# payload should be the name of the label
base_api::delete "$TOKEN" "repos/$OWNER/$GITHUB_REPO/issues/$ISSUE_NUM/labels/$PAYLOAD"
}
function get_all_description() {
local -r TOKEN="$1"
local -r OWNER="$2"
local -r GITHUB_REPO="$3"
body=$(base_api::get "$TOKEN" "repos/$OWNER/$GITHUB_REPO/issues")
echo "$body" | jq -r '.[] | "\(.assignee.login) \(.body)"'
}
function get_issue_title() {
local -r TOKEN="$1"
local -r OWNER="$2"
local -r GITHUB_REPO="$3"
local -r ISSUE_NUM="$4"
body=$(base_api::get "$TOKEN" "repos/$OWNER/$GITHUB_REPO/issues/$ISSUE_NUM")
echo "$body" | jq -r '.title'
}