You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Last Thursday, July 29, Joost and I had a brief discussion on the possibility of automatically creating a new milestone and moving issues to it, and how I surmised that Hugo developers might be already doing it. The day after though, I was surprised by the following tweet:
Dear @github moving 200+ issues from a milestone to another is a surprisingly time consuming process. /cc @natfriedman
(and yes, we have been wining about this before)
So, the Hugo folks were migrating issues to new milestone manually too? 🤔
[Edited 2021-08-10: Probably through GitHub's web interface, e.g. search for is:open is:issue milestone:v0.87, click the "select all" checkbox, then click the Milestone to set a new milestone, e.g. v0.88. Problem is that the "select all" checkbox only selects up to 25 issues while Hugo has 299 open issues. 300 ÷ 25 = 12, i.e. the operation has to be repeated 12 times!?! That is a whole lot of clicking! Maybe that is what the complaint was about.]
Anyhow, GitHub does have an Issues API that can create a milestone and update an issue, for example, so perhaps we can use the Issues API to accomplish what we need.
(Aside: So that was what I started doing last Saturday (I had a memory lapse), but veered off to looking into having github-cli (gh) packaged for Debian.)
This is a test script that successfully move OpenDRR/opendrr-api "Sprint 39" issues to "Sprint 40" milestone. (Tested on Thu 2021-08-05).
Note:
It lives on my computer as ~/bin/milestone-test.sh
GitHub CLI gh automatically replaces {owner} and {repo} based on the Git repo directory that you are in.
This is very preliminary and a proof of concept. The milestones names are hardcoded. No error checking is done whatsoever, at least not yet. Proceed with caution!
#!/bin/bashset -x
OLD_MILESTONE_TITLE="Sprint 39"
NEW_MILESTONE_TITLE="Sprint 40"
OLD_MILESTONE_NUMBER=$(gh api -X GET "repos/{owner}/{repo}/milestones" --jq ".[] | select(.title == \"$OLD_MILESTONE_TITLE\").number")
NEW_MILESTONE_NUMBER=$(gh api -X GET "repos/{owner}/{repo}/milestones" --jq ".[] | select(.title == \"$NEW_MILESTONE_TITLE\").number")# Print open issues in the previous milestone
gh api -X GET "repos/{owner}/{repo}/issues" -f milestone="$OLD_MILESTONE_NUMBER" --jq '.[] | [.number, .title, .assignee.login]'# Move issues to the new milestoneforiin$(gh api -X GET "repos/{owner}/{repo}/issues" -f milestone="$OLD_MILESTONE_NUMBER" -f direction=asc --jq '.[].number');doecho"Moving Issue $i from \"$OLD_MILESTONE_TITLE\" to \"$NEW_MILESTONE_TITLE\"..."
gh api -X GET "repos/{owner}/{repo}/issues/$i">"Issue-${i}-${OLD_MILESTONE_TITLE///-}.json"
gh api -X PATCH "repos/{owner}/{repo}/issues/$i" -f milestone="$NEW_MILESTONE_NUMBER">"Issue-${i}-${NEW_MILESTONE_TITLE///-}.json"done
To create a milestone:
gh api -X POST repos/{owner}/{repo}/milestones -f title="Sprint 40" -f due_on=2021-08-26T15:30:00-07:00
GitHub stores only the date of due_on, but when creating a milestone with -X POST, it needs the whole date+time+timezone string like the above.
No such restriction for changing the due_on with -X PATCH though. For example:
gh api -X PATCH repos/{owner}/{repo}/milestones/35 -f due_on=2021-08-05
TODO:
Expand this script and turn it into something useful that our team can use. Add features such as:
List all open assigned issues
Create new milestone with due date
Make it cross-platform, i.e. can use on Linux, macOS and Windows. (Implies rewriting in Python? Or keep the bash script but provides also .bat / .ps1?)
Another TODO: Remove jq dependency and rely on gh's built-in jq functionality alone.
anthonyfok
changed the title
Automatically create a new milestone and move issues to it
Automatically create new milestone; optionally move issues to it
Oct 12, 2021
Last Thursday, July 29, Joost and I had a brief discussion on the possibility of automatically creating a new milestone and moving issues to it, and how I surmised that Hugo developers might be already doing it. The day after though, I was surprised by the following tweet:
https://twitter.com/GoHugoIO/status/1421181681717944323
So, the Hugo folks were migrating issues to new milestone manually too? 🤔
[Edited 2021-08-10: Probably through GitHub's web interface, e.g. search for
is:open is:issue milestone:v0.87
, click the "select all" checkbox, then click the Milestone to set a new milestone, e.g.v0.88
. Problem is that the "select all" checkbox only selects up to 25 issues while Hugo has 299 open issues. 300 ÷ 25 = 12, i.e. the operation has to be repeated 12 times!?! That is a whole lot of clicking! Maybe that is what the complaint was about.]Anyhow, GitHub does have an Issues API that can create a milestone and update an issue, for example, so perhaps we can use the Issues API to accomplish what we need.
Some on-line posts even suggests the use of GitHub CLI (
gh
) to manage milestones · Issue #1200 · cli/cli.(Aside: So that was what I started doing last Saturday (I had a memory lapse), but veered off to looking into having
github-cli
(gh
) packaged for Debian.)Update: Shared the idea with Hugo at https://discourse.gohugo.io/t/script-to-move-issues-to-new-milestone-proof-of-concept/34181
The text was updated successfully, but these errors were encountered: