FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Ejecting should ensure you have clean git status by milocosmopolitan · Pull Request #2090 · react/create-react-app · GitHub

Ejecting should ensure you have clean git status - #2090

Closed
milocosmopolitan wants to merge 15 commits into
react:masterfrom
milocosmopolitan:eject
Closed

Ejecting should ensure you have clean git status#2090
milocosmopolitan wants to merge 15 commits into
react:masterfrom
milocosmopolitan:eject

Conversation

milocosmopolitan commented May 5, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

Timer commented May 5, 2017

Copy link
Copy Markdown
Contributor

Wow, great! I'll take a peek at this soon.
Thank you!

Timer added this to the 0.10.0 milestone May 5, 2017
Comment thread packages/react-scripts/scripts/eject.js Outdated
}

// Make sure there are no dirty git status
const git = fs.existsSync(path.join(process.cwd(), '.git'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hi @thejameskyle, can you explain what are the benefits of using that library? Is it because it returns promised result? Cause I was trying to avoid using third-party library as possible. If promise is necessary I could just use instantiate Promise.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@milocosmopolitan someone might have their git directory several levels up the tree, especially if it's a monorepo.

However, you shouldn't be checking for the existence of .git at all -- simply execute a git command in the directory and see if it errors out 😄.

Timer May 5, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

See 1288's files for inspiration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@Timer, I've made a change according to your suggestion.

Comment thread packages/react-scripts/scripts/eject.js Outdated
try {
let stdout = execSync(`git status -s`).toString();
let status = { dirty: 0, untracked: 0 };
stdout.trim().split(/\r?\n/).forEach(file => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You might want to use git status --porcelain for easier parsing.

gaearon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

See comment above.

gaearon modified the milestones: 0.11.0, 0.10.0, 0.10.1 May 8, 2017

sunjay left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Cool feature! Thanks for the PR! I saw some things, so I hope you don't mind the extra review. 😄

Comment thread packages/react-scripts/scripts/eject.js Outdated
console.error(
`Git repository has ${status.dirty} dirty ${status.dirty > 1 ? 'files' : 'file'}. ` +
'We cannot continue as you would lose all the changes in that file or directory. ' +
'Please push commit before and run this command again.'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this error message covers all the right bases. The grammar however is a bit confusing.

The first sentence mentions that you have 1 or more dirty files, but then the second sentence only refers to a single file or directory. The third sentence isn't totally clear grammatically and it states that you need to push as well as commit in order to make the directory clean. While pushing may be ideal, it isn't the same as committing and only committing is really necessary here.

What do you think of this as the error message instead?

`This git repository has ${status.dirty} dirty ${status.dirty > 1 ? 'files' : 'file'}. ` +
'We cannot continue as you would lose all of your changes. ' +
'Please commit your changes with `git commit` and then run this command again.'

This way, the user knows what to do to fix the problem and the message is completely clear.

taylorlapeyre May 10, 2017
edited
Loading

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

My attempt at the grammar on this:

`This git repository has ${status.dirty} ${status.dirty > 1 ? 'files' : 'file'} with uncommitted changes.` +
'Ejecting would cause these files to be overwritten. ' +
'Please commit your changes with `git commit` and then run this command again.'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for those suggestions @sunjay, @taylorlapeyre. I personally liked @taylorlapeyre version. I will make an update soon.

Comment thread packages/react-scripts/scripts/eject.js Outdated
function statusSync() {
try {
let stdout = execSync(`git status --porcelain`).toString();
let status = { dirty: 0, untracked: 0 };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If you're also counting untracked files, why isn't that used in the dirty check below? If it shouldn't be used, why is it being counted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You are right, I think untracked files should be exclude. I will make pull request on this tonight.

gaearon removed this from the 1.0.1 milestone May 19, 2017
gaearon modified the milestones: 1.0.x, 1.0.1 May 19, 2017

Timer commented Jun 28, 2017

Copy link
Copy Markdown
Contributor

Hi! Could you please rebase this? I'd love to get this in.

milocosmopolitan commented Jul 2, 2017
edited
Loading

Copy link
Copy Markdown
Contributor Author

@Timer thought it was merged
#2221

Timer commented Jul 2, 2017

Copy link
Copy Markdown
Contributor

Oh, yeah I thought we had. Must've been a duplicate PR.

Timer closed this Jul 2, 2017
lock Bot locked and limited conversation to collaborators Jan 21, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL