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

fix(describe-ref): properly handle sha-like tag names #1853

Merged
merged 1 commit into from
Jan 8, 2019

Conversation

arahansen
Copy link
Contributor

@arahansen arahansen commented Jan 8, 2019

I ran into an issue trying to publish my changes. describe-ref would attempt to find the tags from the upstream, however it incorrectly treated the output as a "minimal sha" as if no tags were found.

This change more strictly checks for minimal sha output. I'm not 100% sure what the output is supposed to look like for these "minimal shas". However, the test I added matches the shape of my repo's tags, and the following is the output when trying to publish without these changes:

lerna ERR! Error: Command failed: git rev-list --count 20190107
[Step 2/3] lerna ERR! fatal: ambiguous argument '20190107': unknown revision or path not in the working tree.
[Step 2/3] lerna ERR! Use '--' to separate paths from revisions, like this:
[Step 2/3] lerna ERR! 'git <command> [<revision>...] -- [<file>...]'
[Step 2/3] lerna ERR! 
[Step 2/3] lerna ERR! 
[Step 2/3] lerna ERR!     at makeError (~/node_modules/execa/index.js:174:9)
[Step 2/3] lerna ERR!     at Function.module.exports.sync (~/node_modules/execa/index.js:338:15)
[Step 2/3] lerna ERR!     at Object.execSync (~/node_modules/@lerna/child-process/index.js:22:16)
[Step 2/3] lerna ERR!     at parse (~/node_modules/@lerna/describe-ref/lib/describe-ref.js:65:35)
[Step 2/3] lerna ERR!     at Function.sync (~/node_modules/@lerna/describe-ref/lib/describe-ref.js:50:18)
[Step 2/3] lerna ERR!     at collectUpdates (~/node_modules/@lerna/collect-updates/collect-updates.js:24:56)
[Step 2/3] lerna ERR!     at VersionCommand.initialize (~/node_modules/@lerna/version/index.js:144:20)

even though git describe seems to be producing a valid response.

Description

Motivation and Context

How Has This Been Tested?

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.

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.

A subtle fix, thanks!

@@ -56,10 +56,11 @@ function sync(options = {}, includeMergedTags) {
}

function parse(stdout, options = {}) {
const minimalShaRegex = /^([0-9a-f]{7,40})(-dirty)?$/;
Copy link
Member

Choose a reason for hiding this comment

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

So basically all we're doing is adding a trailing $ to the combined regex? Huh.

@@ -149,4 +149,16 @@ describe("describeRef.parse()", () => {
sha: "a1b2c3d",
});
});

it("should return metadata for tag names that are sha-like", () => {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks so much for the test!

@evocateur evocateur merged commit 094a1cb into lerna:master Jan 8, 2019
@arahansen arahansen deleted the fix-describe-ref branch January 8, 2019 05:49
@lock
Copy link

lock bot commented Mar 9, 2019

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 Mar 9, 2019
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.

2 participants