Skip to content
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

Use --canary=<value> as prerelease tag, not commit-ish #1020

Merged
merged 2 commits into from Oct 2, 2017
Merged

Use --canary=<value> as prerelease tag, not commit-ish #1020

merged 2 commits into from Oct 2, 2017

Conversation

achingbrain
Copy link
Contributor

@achingbrain achingbrain commented Sep 20, 2017

Description

The docs say we should be able to override the meta suffix by passing the canary flag as a string value. lerna takes this value and tries to use it to work out what range of commits it should consider when publishing a package so you can't actually override the meta suffix unless you use a commit id to do this. Considering the commit id is added to the version number for canary releases anyway this seems redundant.

eg:

This works:

lerna publish --canary
...
Changes:
 - package-1: 1.0.0 => 1.1.0-alpha.0a2f1a97
 - package-1: 1.0.0 => 1.1.0-alpha.0a2f1a97

According to the docs this should work but doesn't:

lerna publish --canary=beta
...
lerna ERR! initialize Error: fatal: bad revision 'beta^..beta'
*kaboom!*

Motivation and Context

It would be useful to be able to override the meta suffix as described in the docs.

Fixes #1008.

How Has This Been Tested?

Added some unit tests for the UpdatedPackagesCollector module and integration tests for the canary flag.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@achingbrain
Copy link
Contributor Author

Hmm, the appveyor builds seem to fail in different ways each time, none of which seem to be related to my changes.

@GeorgeTaveras1231
Copy link

@achingbrain was going to work on this myself but glad to see you got this.

Additionally, I wanted to raise a concern with the lerna maintainers about the role that the canary option value is playing and whether it also needs to be used as the pre-id, even though there is already a flag to define the pre-id. It's not a huge deal but it just feels inconsistent and my response was 🤔 when I realized I could not use --pre-id for this.

@achingbrain
Copy link
Contributor Author

I see what you mean. That said canary works well for my current project which requires per-commit automated CI deployment for internal testing with a manual public release gate.

@evocateur any thoughts on this PR?

@evocateur
Copy link
Member

I appreciate the PR, @achingbrain. I am not generally a fan of "polymorphic" options that we inherited from the more lenient meow cli parser. I would much prefer --preid to be used for this purpose, as @GeorgeTaveras1231 suggested (--canary would always be a boolean, never a string).

--preid's implicit default is "alpha", which is exactly what the (implicit :P) default of --canary-as-string is now. I think that's the long-term solution. In the mean-time, this PR seems reasonable. It's not a breaking change, imo, because the functionality never worked as described during the non-beta 2.x cycle to date.

Copy link
Member

@evocateur evocateur left a comment

Choose a reason for hiding this comment

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

Thanks for your patience, @achingbrain, just a few small fixes and we can get this merged.

const repository = {
rootPath: 'root-path'
};

describe("UpdatedPackagesCollector", () => {
it("should exist", () => {
expect(UpdatedPackagesCollector).toBeDefined();
});

it("needs better tests");
Copy link
Member

Choose a reason for hiding this comment

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

It now has them, thank you! (you can delete this empty test case, if you want)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heh, I left that in because I agree with the sentiment 😉

Will remove.

@@ -13,6 +13,9 @@ import loadPkgManifests from "../helpers/loadPkgManifests";
const lastCommitMessage = (cwd) =>
execa.stdout("git", ["log", "-1", "--format=%B"], { cwd }).then(normalizeNewline);

const lastCommitId = (cwd) =>
execa.stdout("git", ["rev-parse", "HEAD"], { cwd }).then((line) => line.trim().substring(0, 8));
Copy link
Member

Choose a reason for hiding this comment

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

I thought execa automatically trimmed stdout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

const { stdout, stderr } = await execa(LERNA_BIN, args, { cwd });
const hash = await lastCommitId(cwd);
expect(stdout.replace(new RegExp(hash, 'g'), 'hash')).toMatchSnapshot("stdout: canary default version");
expect(stderr).toMatchSnapshot("stderr: canary beta version");
Copy link
Member

Choose a reason for hiding this comment

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

This snapshot label should be stderr: canary default version, looks like copy+paste oversight.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@achingbrain
Copy link
Contributor Author

@evocateur I've made the changes as requested, is there anything else that needs doing before this can be merged? Thanks..

@evocateur evocateur changed the title Fixes #1008 by not using the passed canary flag as a commit id Use --canary=<value> as prerelease tag, not commit-ish Oct 2, 2017
@evocateur evocateur merged commit 5c079a5 into lerna:master Oct 2, 2017
@evocateur
Copy link
Member

@achingbrain Thanks!

@lock
Copy link

lock bot commented Dec 27, 2018

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lerna publish --canary=${my_prerelease_tag} doesn't work
3 participants