Add CommitFunctions and update config with defaults#768
Add CommitFunctions and update config with defaults#768Andarist merged 20 commits intochangesets:mainfrom rohit-gohri:custom-commit-message-script
Conversation
🦋 Changeset detectedLatest commit: 8b855ed The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8b855ed:
|
| if ( | ||
| typeof possibleCommitFunc.getAddLine === "function" && | ||
| typeof possibleCommitFunc.getVersionLine === "function" | ||
| ) { | ||
| getCommitFuncs = possibleCommitFunc; | ||
| } else { | ||
| throw new Error("Could not resolve commit generation functions"); | ||
| } |
There was a problem hiding this comment.
I guess we can start from requiring both to exist - but I wonder if there are people only wanting one of those to kick in 🤔
There was a problem hiding this comment.
We can treat not existing as commit: false for add/version separately.
There was a problem hiding this comment.
Added support for partial functions. If only one of it is supplied then commit will be done for that command only
packages/cli/src/commit/index.ts
Outdated
| Releases: | ||
| ${releasesLines} | ||
|
|
||
| [skip ci] |
There was a problem hiding this comment.
What if we would remove this from here and instead add options to this function and only render this based on smth like options.versionSkipCI === true. This way we could "translate" current commit: true to ["@changesets/cli/commit", { versionSkipCI: true }].
This would be quite nice because one could more easily extend the built-in function without having to strip [skip ci] from it if they don't want it. This option would go away in Changesets v3 (if that ever gets published) and would only be supported now to avoid breaking changes.
There was a problem hiding this comment.
This is a great idea, adds back skipCI but as a different option
There was a problem hiding this comment.
I added for both versionSkipCI and addSkipCI, with versionSkipCI as true for the true config
There was a problem hiding this comment.
addSkipCI seems like a weird option name now that I have added it, WDYT about just having skipCI and possible values being 'version' | 'add' | boolean?
There was a problem hiding this comment.
that works too, I don't mind any of those solutions - I agree that the current names are a little bit weird but since I'd like to remove this in the future anyway... I don't care that much about this :p
There was a problem hiding this comment.
Changed to "skipCI": "version" | "add" | boolean as the option.
packages/cli/src/commit/index.ts
Outdated
|
|
||
| export default defaultCommitFunctions; | ||
|
|
||
| export function getCommitFuncs( |
There was a problem hiding this comment.
is this actually used anywhere? or just in tests?
There was a problem hiding this comment.
It is used in the add function. I wanted to also use it in apply-release-plan but couldn't figure out how that import would work
There was a problem hiding this comment.
I think that it would make sense to introduce a breaking change to the @changesets/apply-release-plan (that would not be a breaking change for the Changesets itself) and just move out the committing logic from it. Based on its return value the "version commit" could be conditionally created within @changesets/cli.
This would make both commit types be performed by a single package - which I think would be a good thing for the codebase.
There was a problem hiding this comment.
Moved to the cli 🙂
|
All done from my side, the only thing remaining is the name of the skipCI options. See this comment |
| while (newTouchedFilesArr.length > 0) { | ||
| let file = newTouchedFilesArr.shift(); | ||
| await git.add(path.relative(cwd, file!), cwd); | ||
| } |
There was a problem hiding this comment.
we don't need to touch this here but it's probably better to construct a single call to git add since stuff like git add file1.js file2.js ... is a totally valid thing to do
There was a problem hiding this comment.
The add function in @changesets/git only accepts one path so I'm going to leave this for now.
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
|
The PR is almost ready to be shipped, great work! Once all remaining items (mostly nits really) get addressed I will rethink the rollout strategy as we need to consider how this affects the version of the involved packages and how to ensure that this doesn't break any existing consumers. |
|
I would love to see this PR merged as soon as possible. What's holding it back? Really looking forward to being able to turn auto-commit back on without getting that |
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Lack of the free time of maintainers 😉 |
|
@rohit-gohri thank you very much for your contributions and bearing with me. People like you keep OSS projects afloat 🚀 |
|
Thanks a lot guys, really awesome! Works as advertised for me. However, it does look like |
Yeah, we forgot about it - PR with an update would be appreciated. |
Follow up of #735
Closes #688
Closes #285
Made commit option similar to changelog option but with a default template when "true" is passed (keeping it backward compatible).
This currently doesn't allow disabling commit for one of add/version. Maybe that can be added too if the respective function returns null or doesn't exist?If one of the functions doesn't exist then we will not commit for that only.