-
Notifications
You must be signed in to change notification settings - Fork 39
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
Sanitize git branch names #271
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right fix, according to the issue, the tag wasn't what caused troubles but the branch created on the local opam-repository repo was. It's indeed likely that the tag needs to be sanitized as well but this change has other implications.
Changing the tag will change the version number we use accross the whole tool and that's not something we want, there are places where we want the actual version provided by the user (in the CHANGELOG) I mean.
I think we need to distinguish those first and have a clear policy, where we use the provided version number as much as possible and only sanitize when strictly necessary! We could even introduce a type for sanitized names to prevent further issues with this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we use the tag in most places instead of the actual version and that's what I'd like to avoid, i.e. only use a sanitized string where it is strictly necessary.
How about the following:
- we create a
Git.branch_or_tag_name
type and astring -> branch_or_tag_name
function. Internally it should probably just be a string. - we make it so that the functions that do the tagging or branch creation take that type as an input
That way we have an abtract type that can't be wrongly used elsewhere. What do you think?
I rebased the branch and made substitutions more explicit (for example |
I just gave this a spin and it seems it replaces the characters pretty much everywhere:
Before this the tag would be equal to the version in the changelog and therefor the version in the changelog would be used everywhere. I think that should remain true and we should only rewrite it for git branches and tags. I know we use the tag in the code to get the version so I suggest we do one of two things:
What do you think? |
I addressed your last review, now the substitutions should only be made for the tags/branches, and we don't need to reverse it, on the other hand we rely on the tag from the changelog to create the name of the archive and so on (with a fallback to the git tag name if no changelog is present). I've kept the changes in the mli files (some types changing from The "Distribution ..." name for tags is set by |
Master is indeed broken |
I've rebased this PR, and made sure we only sanitize the name and not the tag_name of a release. |
I tested it to make sure it all works and there are a few things to note:
This is purely a user experience thing but I wonder if it shouldn't use the name for the release here, i.e.:
That's more of an open question, I feel like it should use the future release name here in the logs. What do you think?
|
I fixed this, and also the message associated to the tag set by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good! Thanks, I think this is a great change.
I have added a few minor remarks. One thing I also want to mention is that the cram test is a bit verbose, I'm not sure we need all of the logs. Do you think we could eventually grep for the parts we care about?
Otherwise there's going to be diffs very often there, we'll get use to it and simply always promote until one day we actually miss a meaningful change in the output.
Another thing is that it might be useful to make commit_ish
abstract and provide pretty printers and/or a to_string
function but we don't have to do this straight away, the change is already valuable as it is.
I've filtered the output of the cram test with (part of) the tag name so we only get the unsanitized version and the sanitized tag in the output.
It sounds good to me, but it can be done in another PR indeed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks!
That's a great feature and I think people are really going to enjoy being able to release beta versions with dune-release!
CHANGES: ### Added - Add `--no-auto-open` to the default command. It was previously only available for `dune-release opam`. (tarides/dune-release#374, @NathanReb) - Add a `config create` subcommand to create a fresh configuration if you don't have one yet (tarides/dune-release#373, @NathanReb) - Add `--local-repo`, `--remote-repo` and `--opam-repo` options to the default command, they used to be only available for the `opam` subcommand (tarides/dune-release#363, @NathanReb) - Add a `--token` option to `dune-release publish` and `dune-release opam` commands to specify a github token. This allows dune-release to be called through a Github Actions workflow and use the github token through an environment variable. (tarides/dune-release#284 tarides/dune-release#368, @gpetiot @NathanReb) - Log curl calls on verbose/debug mode (tarides/dune-release#281, @gpetiot) - Try to publish the release asset again after it failed (tarides/dune-release#272, @gpetiot) - Improve error reporting of failing git comands (tarides/dune-release#257, @gpetiot) - Suggest a solution for users without ssh setup (tarides/dune-release#304, @pitag-ha) - Allow including git submodules to the distrib tarball by passing the `--include-submodules` flag to `dune-release`, `dune-release bistro` or `dune-release distrib` (tarides/dune-release#300, @NathanReb) - Support 'git://' scheme for dev-repo uri (tarides/dune-release#331, @gpetiot) - Support creation of draft releases and draft PRs. Define a new option `--draft` for `dune-release publish` and `dune-release opam submit` commands. (tarides/dune-release#248, @gpetiot) - Add a new command `check` to check the prerequisites of dune-release and avoid starting a release process that couldn't be finished (tarides/dune-release#318, tarides/dune-release#351, @pitag-ha) - When preparing the opam-repository PR and pushing the local branch to the user's remote opam-repository fork, use `--set-upstream` to ease any further update of the PR (tarides/dune-release#350, @gpetiot) ### Changed - Entirely rely on the remote fork of opam-repository URL in `opam submit` instead of reading the user separately. The information was redundant and could only lead to bugs when unproperly set. (tarides/dune-release#372, @NathanReb) - Use pure token authentication for Github API requests rather than "token as passwords" authentication (tarides/dune-release#369, @NathanReb) - Require tokens earlier in the execution of commands that use the github API. If the token isn't saved to the user's configuration, the prompt for creating one will show up at the command startup rather than on sending the first request (tarides/dune-release#368, @NathanReb) - Attach the changelog to the annotated tag message (tarides/dune-release#283, @gpetiot) - Do not remove versioned files from the tarball anymore. We used to exclude `.gitignore`, `.gitattributes` and other such files from the archive. (tarides/dune-release#299, @NathanReb) - Don't try to push the tag if it is already present and point to the same ref on the remote. `dune-release` must guess which URI to pass to `git push` and may guess it wrong. This change allows users to push the tag manually to avoid using that code. (tarides/dune-release#219, @Julow) - Don't try to create the release if it is already present and points to the same tag (tarides/dune-release#277, @kit-ty-kate) - Recursively exclude all `.git`/`.hg` files and folders from the distrib tarball (tarides/dune-release#300, @NathanReb) - Make the automatic dune-release workflow to stop if a step exits with a non-zero code (tarides/dune-release#332, @gpetiot) - Make git-related mdx tests more robust in unusual environments (tarides/dune-release#334, @sternenseemann) - Set the default tag message to "Release <tag>" instead of "Distribution <tag>" - Opam file linter: check for `synopsis` instead of `description` (tarides/dune-release#291, @kit-ty-kate) - Upgrade the use of the opam libraries to opam 2.1 (tarides/dune-release#343, @kit-ty-kate) ### Deprecated - Deprecate the `--user` CLI options and configuration field, they were redundant with the remote-repo option and field and could be set unproperly, leading to bugs (tarides/dune-release#372, @NathanReb) - Deprecate the use of delegates in `dune-release publish` (tarides/dune-release#276, tarides/dune-release#302, @pitag-ha) - Deprecate the use of opam file format 1.x (tarides/dune-release#352, @NathanReb) ### Removed - Option --name is removed from all commands. When used with `dune-release distrib`, it was previously effectively ignored. Now it is required to add a `(name <name>)` stanza to `dune-project`. (tarides/dune-release#327, @lehy) ### Fixed - Fix a bug where `opam submit` would look up a config file, even though all the required information was provided on the command line. This would lead to starting the interactive config creation quizz if that file did not exist which made it impossible to use it in a CI for instance. (tarides/dune-release#373, @NathanReb) - Fix a bug where `opam submit` would fail on non-github repositories if the user had no configuration file (tarides/dune-release#372, @NathanReb) - Fix a bug where subcommands wouldn't properly read the token files, leading to authentication failures on API requests (tarides/dune-release#368, @NathanReb) - Fix a bug in `opam submit` preventing non-github users to create the opam-repo PR via dune-release. (tarides/dune-release#359, @NathanReb) - Fix a bug where `opam submit` would try to parse the custom URI provided through `--distrib-uri` as a github repo URI instead of using the dev-repo (tarides/dune-release#358, @NathanReb) - Fix the priority of the `--distrib-uri` option in `dune-release opam pkg`. It used to have lower precendence than the url file written by `dune-release publish` and therefore made it impossible to overwrite it if needed. (tarides/dune-release#255, @NathanReb) - Fix a bug with --distrib-file in `dune-release opam pkg` where you would need the regular dune-release generated archive to be around even though you specified a custom distrib archive file. (tarides/dune-release#255, @NathanReb) - Use int64 for timestamps. (tarides/dune-release#261, @gpetiot) - Define the order of packages (tarides/dune-release#263, @gpetiot) - Allow the dry-run mode to continue even after some API call's response were expected by using placeholder values (tarides/dune-release#262, @gpetiot) - Build and run tests for all selected packages when checking distribution tarball (tarides/dune-release#266, @NathanReb) - Improve trimming of the changelog to preserve the indentation of the list of changes. (tarides/dune-release#268, @gpetiot) - Trim the data of the `url` file before filling the `url.src` field. This fixes an issue that caused the `url.src` field to be a multi-line string instead of single line. (tarides/dune-release#270, @gpetiot) - Fix a bug causing dune-release to exclude all hidden files and folders (starting with `.`) at the repository from the distrib archive (tarides/dune-release#298, @NathanReb) - Better report GitHub API errors, all of the error messages reported by the GitHub API are now checked and reported to the user. (tarides/dune-release#290, @gpetiot) - Fix error message when `dune-release tag` cannot guess the project name (tarides/dune-release#319, @lehy) - Always warn about uncommitted changes at the start of `dune-release distrib` (tarides/dune-release#325, @lehy). Otherwise uncommitted changes to dune-project would be silently ignored by `dune-release distrib`. - Fix rewriting of github references in changelog (tarides/dune-release#330, @gpetiot) - Fixes a bug under cygwin where dune-release was unable to find the commit hash corresponding to the release tag (tarides/dune-release#329, @gpetiot) - Fixes release names by explicitly setting it to match the released version (tarides/dune-release#338, @NathanReb) - Fix a bug that prevented release of a package whose version number contains invalid characters for a git branch. The git branch names are now sanitized. (tarides/dune-release#271, @gpetiot) - `publish`: Fix the process of inferring user name and repo from the dev repo uri (tarides/dune-release#348, @pitag-ha)
Fix #216