| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Wow, great! I'll take a peek at this soon. |
Sorry, something went wrong.
| } | ||
|
|
||
| // Make sure there are no dirty git status | ||
| const git = fs.existsSync(path.join(process.cwd(), '.git')); |
There was a problem hiding this comment.
You might want to use https://github.com/sindresorhus/find-up
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
@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 😄.
Sorry, something went wrong.
There was a problem hiding this comment.
See 1288's files for inspiration.
Sorry, something went wrong.
There was a problem hiding this comment.
@Timer, I've made a change according to your suggestion.
Sorry, something went wrong.
| try { | ||
| let stdout = execSync(`git status -s`).toString(); | ||
| let status = { dirty: 0, untracked: 0 }; | ||
| stdout.trim().split(/\r?\n/).forEach(file => { |
There was a problem hiding this comment.
You might want to use git status --porcelain for easier parsing.
Sorry, something went wrong.
There was a problem hiding this comment.
See comment above.
Sorry, something went wrong.
There was a problem hiding this comment.
Cool feature! Thanks for the PR! I saw some things, so I hope you don't mind the extra review. 😄
Sorry, something went wrong.
| 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.' |
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
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.'
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for those suggestions @sunjay, @taylorlapeyre. I personally liked @taylorlapeyre version. I will make an update soon.
Sorry, something went wrong.
| function statusSync() { | ||
| try { | ||
| let stdout = execSync(`git status --porcelain`).toString(); | ||
| let status = { dirty: 0, untracked: 0 }; |
There was a problem hiding this comment.
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?
Sorry, something went wrong.
There was a problem hiding this comment.
You are right, I think untracked files should be exclude. I will make pull request on this tonight.
Sorry, something went wrong.
|
Hi! Could you please rebase this? I'd love to get this in. |
Sorry, something went wrong.
Sorry, something went wrong.
|
Oh, yeah I thought we had. Must've been a duplicate PR. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
#2082