Add support for setting ZMK version#53
Conversation
|
Looks good thanks, I think we need to update the version in https://github.com/zmkfirmware/unified-zmk-config-template/blob/main/.github/workflows/build.yml as well. |
|
|
||
| # ls-remote output is "<hash> refs/tags/<tag>" for each tag. | ||
| # Return only the text after "refs/tags/". | ||
| tags = (line.split()[-1].removeprefix("refs/tags/") for line in lines) |
There was a problem hiding this comment.
Do we want to append main here or assume folks who need it would know to do zmk version main (which is also mentioned in the help message)?
There was a problem hiding this comment.
I was considering the ability to specify a particular commit or branch as more of a power user thing. Having main show up in zmk version --list but not any other branches feels a little weird, but I guess it is more of a special case branch.
I think I'm leaning towards leaving it out, and if anyone complains, we can add it.
Done. Also changed it to set the default revision instead of the revision on the "zmk" project to match the current config template, plus fixed some issues that were changing the formatting of the file unintentionally. |
| name: Annotated[ | ||
| str | None, | ||
| typer.Argument(help="Directory name where the repo should be cloned."), | ||
| ] = None, |
There was a problem hiding this comment.
It might be worth making one of these an Option, e.g. to be able to specify the name without the url. I'd vote for url to be an option and name to stay an argument.
There was a problem hiding this comment.
I was following https://git-scm.com/docs/git-clone for this
There was a problem hiding this comment.
I guess using the interactive mode asks for both separately, so it isn't very important either way.
Added a new "zmk version" command which can print the current ZMK version, list available tagged versions, and switch to a new version. Also added a new Remote class, which queries information about remote Git repositories, and some new utility methods on Repo to get remote and West manifest information. Updated some existing commands to use these. Partially implements zmkfirmware#52
The "zmk init" command now supports arguments for setting the URL and clone directory directly instead of prompting for them. It also now has a --zmk-version option, which switches to the given revision of ZMK prior to running "west update". If the selected revision does not exist, then it leaves the version unchanged. Finishes implementing zmkfirmware#52
Updated the YAML editing code to work around an issue where blank lines and multi-line comments weren't handled correctly, resulting in blank lines getting deleted and new blank lines getting inserted in comments. Also changed the default indentation to match what is used in the ZMK config template, and enabled preserving quotes by default.
Provided the user is still using the default GitHub workflow, the "zmk version" command will now update that to point to the correct revision of ZMK as well. Also reworked the logic for updating the version in the West manifest to set manifest.defaults.revision instead of setting the revision on the ZMK project. This matches what is now done in the config template, which allows updating the version in one place for any modules that tag commits to match ZMK versions.
63eccb7 to
bec7c23
Compare
Added a new
zmk versioncommand, which can get the current ZMK version, change the version, and print available versions.Updated
zmk initwith new options including one to set the ZMK version immediately.Implements #52