Comments (4)
Unable to successfully push new branch.
Outer git push -u
will fail with process.exit(1)
.
The inner git push
cannot get the specified branch name, resulting in the inability to git push remote branch
Running git branch --set-upstream-to
before git push
will not work because the remote does not have this branch.
If the outer process.exit(0)
will cause the push not to be the latest commit.
There are two solutions:
- Filter out the repeated
npm version
, that is, the last commit was a modified version, then the version is not modified this time, justprocess.exit(0)
. If you runnpm version
, you need to executegit push
again after the currenthook
returns to ensure that the latest commit is pushed. - Submit pr to git and pass
-u
andbranch
parameters topre-push
.
from git-scripts.
The git push
hook definitely should be improved.
Let's try to find some solutions to make it better and we can discuss it in our next community meeting.
from git-scripts.
I think this problem can be solved by the new feature of git-push hook.
refer to:
pre-push
~~~~~~~~
This hook is called by linkgit:git-push[1] and can be used to prevent
a push from taking place. The hook is called with two parameters
which provide the name and location of the destination remote, if a
named remote is not being used both values will be the same.
Information about what is to be pushed is provided on the hook's standard
input with lines of the form:
<local ref> SP <local object name> SP <remote ref> SP <remote object name> LF
For instance, if the command +git push origin master:foreign+ were run the
hook would receive a line like the following:
refs/heads/master 67890 refs/heads/foreign 12345
although the full object name would be supplied. If the foreign ref does not
yet exist the `<remote object name>` will be the all-zeroes object name. If a
ref is to be deleted, the `<local ref>` will be supplied as `(delete)` and the
`<local object name>` will be the all-zeroes object name. If the local commit
was specified by something other than a name which could be expanded (such as
`HEAD~`, or an object name) it will be supplied as it was originally given.
If this hook exits with a non-zero status, `git push` will abort without
pushing anything. Information about why the push is rejected may be sent
to the user by writing to standard error.
I haven't confirmed which version of git this feature is from, and I hope it can be used as soon as possible.
from git-scripts.
After testing, this feature has been supported in earlier versions.
I tested the two versions installed on the mac, and they all work
-
git version 2.21.1 (Apple Git-122.3)
-
git version 2.35.1
-
pre-push
file:
#!/usr/bin/env node
var path = require('path')
, scripts = require('../../')
, name = path.basename(__filename)
, project = scripts();
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question('', data => {
console.log('input data:', data)
readline.close()
});
console.log('args:',JSON.stringify(process.argv.slice(2)));
setTimeout(() => {
process.exit(-1);
}, 1000);
- test:
> git push origin test
args: ["origin","[email protected]:binsee/sidecar.git"]
refs/heads/test 65b8bd5bd8e8c889fb8ec6228cfada35164cc423 refs/heads/test 0000000000000000000000000000000000000000
input data: refs/heads/test 65b8bd5bd8e8c889fb8ec6228cfada35164cc423 refs/heads/test 0000000000000000000000000000000000000000
According to the official documentation, this feature has been supported since at least the 2015 version of git 2.2.3.
So, we can use this feature to improve pre-push
.
from git-scripts.
Related Issues (9)
- Action required: Greenkeeper could not be activated 🚨
- Show a hint for how to disable pre-push hook in the error message HOT 7
- Does npm version really need tag ? HOT 5
- Cannot find module '../package.json'
- Upgrade guide HOT 1
- npm run lint may not output error messages when running errors HOT 2
- Should we allow skipping lint checks? HOT 1
- unknown revision or path not in the working tree
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from git-scripts.