Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hack: add default-branches-report.sh #2886

Merged
merged 1 commit into from
Aug 10, 2021
Merged
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
hack: add default-branches-report.sh
outputs a github-flavored markdown checklist of repos per org, with
checkboxes checked if their default branch is named something other than
'master'

run with no args to target the orgs managed by the kubernetes
github-management subproject
spiffxp committed Aug 9, 2021
commit af53285742ccab27bebf070096cf90b919a31f89
57 changes: 57 additions & 0 deletions hack/default-branches-report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash

# Copyright 2021 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

readonly kubernetes_orgs=(
kubernetes
kubernetes-sigs
kubernetes-client
kubernetes-csi
)

readonly gh_api_cmd=(
gh api
--field=per_page=100
--paginate
--method=GET
)

function ensure_dependencies() {
if ! command -f gh >/dev/null; then
>&2 echo "gh not found. Please install: https://cli.github.com/manual/installation"
exit 1
fi
}

function main() {
local orgs=("$@")
ensure_dependencies
for org in "${orgs[@]}"; do
echo "* ${org}"
"${gh_api_cmd[@]}" "/orgs/${org}/repos" \
--field=sort=full_name \
--template \
'{{range .}} * [{{if eq .default_branch "master"}} {{else}}X{{end}}] [{{.full_name}}]({{.html_url}}) {{"\n"}}{{end}}'
done
echo
echo "Manual inspection required if you want to link issues that tracked default branch name migration"
}

args=("${@:1}")
if [ ${#args[@]} -eq 0 ]; then
args=("${kubernetes_orgs[@]}")
fi

main "${args[@]}"