-
Notifications
You must be signed in to change notification settings - Fork 934
Move prepush scripts to precommit #3026
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
Conversation
tools/gitHooks/license.js
Outdated
@@ -115,26 +115,24 @@ async function doLicenseCommit(changedFiles) { | |||
symbol: '✅' | |||
}); | |||
|
|||
const hasDiff = await git.diff(); | |||
// Diff unstaged (prettier writes) against staged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license writes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
tools/gitHooks/precommit.js
Outdated
@@ -59,7 +82,18 @@ $ git stash pop | |||
await doLicenseCommit(changedFiles); | |||
|
|||
// Generate API reports | |||
await doApiReportsCommit(); | |||
await doApiReportsCommit(changedFiles); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove Commit
from the function names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
// Diff staged changes against last commit. Don't do an empty commit. | ||
const postDiff = await git.diff(['--cached']); | ||
if (!postDiff) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this condition will never be true since we are committing something from the staging area to begin with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a case I ran into while testing where if you only make formatting changes, and they are wrong, and Prettier reformats them back the way they were, there is no longer a diff between your changes and the last commit. I don't think this would ever happen on push but it could happen on a small commit if you did a lot of undos and don't realize the only remaining changes are formatting.
Removed API report step because it has been removed in #3030 |
Fetch master branch before diffing Each process diff unstaged against staged Make sure API report uses same diff Revert firestore file Restore merge-base behavior Clearer comment
Moved prepush scripts (prettier, license, api-report) to run on precommit. Since they now run on staged and not committed files, they only
git add
and do not create commits. Some changes have been made to properly diff staged files against master, or staged files against unstaged files, as appropriate.Also attempts to fetch
origin/master
before diffing to reduce anomalies caused by stale clones.