Skip to content
Merged
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
4 changes: 4 additions & 0 deletions gh-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,10 @@ Gets info about an enterprise using the [EnterpriseOwnerInfo](https://docs.githu

Gets the status of a [GitHub Enterprise Importer (GEI) migration](https://docs.github.com/en/enterprise-cloud@latest/migrations/using-github-enterprise-importer/migrating-organizations-with-github-enterprise-importer/migrating-organizations-from-githubcom-to-github-enterprise-cloud?tool=api#step-3-check-the-status-of-your-migration).

### get-issue-type-of-issue.sh

Gets the issue type of an issue. See: [Community Discussions Post](https://github.com/orgs/community/discussions/139933)

### get-label-usage-in-repository.sh

Gets the usage of a label in a repository. Returns data in table format.
Expand Down
2 changes: 2 additions & 0 deletions gh-cli/add-sub-issue-to-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ mutation($parrentIssueId: ID!, $childIssueId: ID!) {
title
number
url
id
issueType {
name
}
Expand All @@ -63,6 +64,7 @@ mutation($parrentIssueId: ID!, $childIssueId: ID!) {
title
number
url
id
issueType {
name
}
Expand Down
59 changes: 59 additions & 0 deletions gh-cli/get-issue-type-of-issue.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Gets the issue type of an issue

if [ -z "$3" ]; then
echo "Usage: $0 <org> <repo> <issue-number>"
echo "Example: ./get-issue-type-of-issue.sh joshjohanning-org migrating-ado-to-gh-issues-v2 5"
exit 1
fi

org="$1"
repo="$2"
issue_number="$3"

# Define color codes
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

# Fetch the issue ID given the issue number
issue=$(gh api graphql -H GraphQL-Features:issue_types -f owner="$org" -f repository="$repo" -F number="$issue_number" -f query='
query ($owner: String!, $repository: String!, $number: Int!) {
repository(owner: $owner, name: $repository) {
issue(number: $number) {
title
number
url
id
issueType {
name
}
}
}
}')

# Check if the query was successful
if [ $? -ne 0 ]; then
echo -e "${RED}Issue #$issue_number not found in $org/$repo${NC}"
exit 1
fi

# Extract and format the issue details using jq
formatted_issue=$(echo "$issue" | jq -r '
.data.repository.issue | {
title: .title,
number: .number,
url: .url,
id: .id,
issueType: .issueType.name
}')

# Print the formatted issue details
echo "$formatted_issue" | jq .

# Check if issue type is null and print a warning
issue_type=$(echo "$formatted_issue" | jq -r '.issueType')
if [ "$issue_type" = "null" ]; then
echo -e "${YELLOW}Warning: No issue type for $org/$repo#$issue_number.${NC}"
fi
11 changes: 10 additions & 1 deletion gh-cli/get-parent-issue-of-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ issue_number="$3"

# Define color codes
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

# Fetch the issue ID given the issue number
Expand Down Expand Up @@ -41,6 +42,7 @@ query($issueId: ID!) {
title
number
url
id
issueType {
name
}
Expand All @@ -61,8 +63,15 @@ formatted_parent_issue=$(echo "$parent_issue" | jq -r '
title: .title,
number: .number,
url: .url,
issueType: .issueType
id: .id,
issueType: .issueType.name
}')

# Print the formatted parent issue details
echo "$formatted_parent_issue" | jq .

# Check if parent issue is null and print a warning
number=$(echo "$formatted_parent_issue" | jq -r '.number')
if [ "$number" = "null" ]; then
echo -e "${YELLOW}Warning: No parent issue for $org/$repo#$issue_number.${NC}"
fi
10 changes: 9 additions & 1 deletion gh-cli/get-sub-issues-of-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ issue_number="$3"

# Define color codes
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

# Fetch the issue ID given the issue number
Expand Down Expand Up @@ -43,6 +44,7 @@ query($issueId: ID!, $endCursor: String) {
title
number
url
id
issueType {
name
}
Expand All @@ -66,8 +68,14 @@ fi
combined_result=$(echo "$sub_issues" | jq -s '
{
totalCount: .[0].data.node.subIssues.totalCount,
issues: (map(.data.node.subIssues.nodes) | add)
issues: (map(.data.node.subIssues.nodes) | add | map(.issueType = .issueType.name))
}')

# Print the combined result as a colorized JSON object
echo "$combined_result" | jq .

# Check if total is 0 and print a warning
total=$(echo "$combined_result" | jq -r '.totalCount')
if [ "$total" -eq 0 ]; then
echo -e "${YELLOW}Warning: The total number of sub-issues for $org/$repo#$issue_number is 0.${NC}"
fi
1 change: 1 addition & 0 deletions gh-cli/remove-issue-issue-type.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ mutation($issueId: ID!) {
title
number
url
id
issueType {
name
}
Expand Down
2 changes: 2 additions & 0 deletions gh-cli/remove-sub-issue-from-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ mutation($parrentIssueId: ID!, $childIssueId: ID!) {
title
number
url
id
issueType {
name
}
Expand All @@ -85,6 +86,7 @@ mutation($parrentIssueId: ID!, $childIssueId: ID!) {
title
number
url
id
issueType {
name
}
Expand Down
1 change: 1 addition & 0 deletions gh-cli/update-issue-issue-type.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ mutation($issueId: ID!, $issueTypeId: ID!) {
title
number
url
id
issueType {
name
}
Expand Down