forked from hazelcast/backport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backport.functions
executable file
·43 lines (31 loc) · 941 Bytes
/
backport.functions
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
#!/bin/bash
set -e
function get_pr_number() {
local commit_msg=$1
echo "$commit_msg" | grep --extended-regexp --only-matching '#[0-9]+' | tail -n1 | cut -c2-
}
function get_pr_reviewers() {
local repo_upstream=$1
local pr_number=$2
gh api "repos/${repo_upstream}/pulls/${pr_number}/reviews" --jq '[.[] | select(.state == "APPROVED") | .user.login] | unique | join(",")'
}
function get_pr_labels() {
local repo_upstream=$1
local pr_number=$2
gh api "repos/${repo_upstream}/pulls/${pr_number}" --jq '[.labels[].name] | join(",")'
}
function check_if_milestone_in_repo() {
local repo_upstream=$1
local milestone=$2
response=$(gh api "repos/${repo_upstream}/milestones?state=all" --paginate --jq ".[] | select(.title == \"${milestone}\")")
if [[ -n "${response}" ]]; then
echo true
else
echo false
fi
}
# upstream/5.2.z -> 5.2z
function get_branch_from_ref() {
local ref=$1
echo "${ref#*/}"
}