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

feat(publish): Add option --no-git-reset to leave unstaged changes in working tree #1791

Merged
merged 2 commits into from
Nov 23, 2018
Merged

feat(publish): Add option --no-git-reset to leave unstaged changes in working tree #1791

merged 2 commits into from
Nov 23, 2018

Conversation

yoitsro
Copy link
Contributor

@yoitsro yoitsro commented Nov 22, 2018

Description

Adds a flag which allows the user to specify whether or not the working tree should be reset or not. Defaults to true so the tree is always reset.

Motivation and Context

When used in CI (specifically for my staging builds), I want lerna to be able to publish canary versions of my packages which can then be consumed in a subsequent docker build step. Right now, once the package versions are bumped, the working tree is then reset meaning that the docker build of the package which depends on the bumped package, refers to the original package version.

Relates to this comment #962 (comment) in #962.

How Has This Been Tested?

  • Unit tests
    Added a unit test to ensure that when --no-git-reset is specified, gitCheckout isn't called.
  • Integration tests
    Added an integration test to ensure that when --no-git-reset is specified, the working tree is left dirty.

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.
    One test was already failing on my machine:
    isAnythingCommitted without and with a commit

Allows for publishes to leave the working tree dirty.
Useful if modified package versions need to be persisted
for future use (i.e. Docker builds).

Relates to #962
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.

My comment isn't blocking, thanks so much for your contribution!

- package-3@1.0.1-alpha.0+SHA
`);

const { stdout: statusStdOut } = await gitStatus();
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we need an entire helper just to run git status, and in any case, a better snapshot would be tightly focused on just the modified files, which is already used elsewhere:

Suggested change
const { stdout: statusStdOut } = await gitStatus();
const modified = await execa.stdout("git", ["ls-files", "--modified"], { cwd });

modified in this case is just a newline-separated list of relative file paths, easily snapshotted inline.

@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
@yoitsro yoitsro deleted the feat/no-git-reset branch December 29, 2018 14:16
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.

None yet

2 participants