Skip to content

Conversation

@yaswant
Copy link
Collaborator

@yaswant yaswant commented Dec 2, 2025

Description

Summary

Add few helper scripts to assist GitHub admin tasks.

Checklist

  • I have performed a self-review of my own changes

@yaswant yaswant self-assigned this Dec 2, 2025
Copy link
Collaborator

@james-bruten-mo james-bruten-mo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks sensible to me. Passing to Sam to also have a look

@james-bruten-mo james-bruten-mo requested a review from t00sa December 3, 2025 13:37
Copy link
Contributor

@t00sa t00sa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've suggested some extra code to prevent admins from removing their own access from a repository, but looks good otherwise.

remove_collaborator() {
local repo_name="$1"
local repo_api="/repos/${OWNER}/${repo_name}/collaborators/${USERNAME}"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have a check which prevents users from removing their own account, e.g.

Suggested change
if [[ $(gh api user --jq ".login") == $USERNAME ]]; then
echo "Cannot remove the current user"
return
fi

Copy link
Collaborator Author

@yaswant yaswant Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @t00sa - that perfectly sensible suggestion. However, I am including the suggested check outside of the helper function to reduce API calls.

Suggestion implemented in: e9bce89

Copy link
Contributor

@t00sa t00sa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks sensible. Approved.

@t00sa t00sa merged commit cc4978a into MetOffice:main Dec 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants