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
20 changes: 20 additions & 0 deletions gh-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,26 @@ Generates a CSV with 4 columns:

This script is useful when doing migrations, to determine the kind of actions that might be needed based on the webhooks inventory.

### get-repositories-with-copilot-instructions.sh

Get repositories that have Copilot custom instruction files, checking for both repository-wide (`.github/copilot-instructions.md`) and path-specific (`.github/instructions/`) instructions

Usage:

```shell
./get-repositories-with-copilot-instructions.sh my-org
```

### get-repositories-without-copilot-instructions.sh

Get repositories that do not have any Copilot custom instruction files (neither `.github/copilot-instructions.md` nor `.github/instructions/`)

Usage:

```shell
./get-repositories-without-copilot-instructions.sh my-org
```

### get-repository-languages-for-organization.sh

Get the repository language information (ie: JavaScript, Python, etc) for all repositories in an organization. Can specify how many language results to return (top X).
Expand Down
55 changes: 55 additions & 0 deletions gh-cli/get-repositories-with-copilot-instructions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# Get repositories that have Copilot custom instruction files
# Checks for:
# - .github/copilot-instructions.md (repository-wide custom instructions)
# - .github/instructions/ directory (path-specific custom instructions)
#
#
# Authentication:
# Requires a GitHub CLI token with at least read:org and repo scopes
# Example: gh auth refresh -h github.com -s read:org,repo
#
# Usage:
# ./get-repositories-with-copilot-instructions.sh <org>
# If you want to see the results in a nicely formatted table, you can pipe the output to `column`:
# ./get-repositories-with-copilot-instructions.sh <org> | column -ts $'\t'

if [ -z "$1" ]; then
echo "Usage: $0 <org>"
exit 1
fi

org=$1

echo -e "Repository\tRepo-Wide\tPath-Specific Files"

gh api graphql --paginate -F owner="$org" -H "X-Github-Next-Global-ID: 1" -f query='
query ($owner: String!, $endCursor: String = null) {
organization(login: $owner) {
repositories(
first: 100
orderBy: { field: NAME, direction: ASC }
after: $endCursor
) {
totalCount
pageInfo {hasNextPage endCursor}
nodes {
nameWithOwner
repoWide: object(expression: "HEAD:.github/copilot-instructions.md") {
... on Blob {
byteSize
}
}
pathSpecific: object(expression: "HEAD:.github/instructions/") {
... on Tree {
entries {
path
}
}
}
}
}
}
}
' --jq '.data.organization.repositories.nodes[] | select(.repoWide != null or .pathSpecific != null) | [.nameWithOwner, (if .repoWide != null then "yes" else "no" end), (if .pathSpecific != null then (.pathSpecific.entries | length | tostring) else "0" end)] | @tsv'
50 changes: 50 additions & 0 deletions gh-cli/get-repositories-without-copilot-instructions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Get repositories that do not have any Copilot custom instruction files
# Checks for the absence of both:
# - .github/copilot-instructions.md (repository-wide custom instructions)
# - .github/instructions/ directory (path-specific custom instructions)
#
Comment thread
joshjohanning marked this conversation as resolved.
# Authentication:
# Requires a GitHub CLI token with at least read:org and repo scopes
# Example: gh auth refresh -h github.com -s read:org,repo
#
# Usage:
# ./get-repositories-without-copilot-instructions.sh <org>

if [ -z "$1" ]; then
echo "Usage: $0 <org>"
exit 1
fi

org=$1

gh api graphql --paginate -F owner="$org" -H "X-Github-Next-Global-ID: 1" -f query='
query ($owner: String!, $endCursor: String = null) {
organization(login: $owner) {
repositories(
first: 100
orderBy: { field: NAME, direction: ASC }
after: $endCursor
) {
totalCount
pageInfo {hasNextPage endCursor}
nodes {
nameWithOwner
repoWide: object(expression: "HEAD:.github/copilot-instructions.md") {
... on Blob {
byteSize
}
}
pathSpecific: object(expression: "HEAD:.github/instructions/") {
... on Tree {
entries {
path
}
}
}
}
}
}
}
' --jq '.data.organization.repositories.nodes[] | select(.repoWide == null and .pathSpecific == null) | .nameWithOwner'
Loading