Open xlr-8 opened 7 years ago
Inspecting the hook files, the only place where it references origin
is the line 12 so it looks that the problem is when the value of the variable BRANCH
isn't a name of an existing branch which is calculate from the previous line.
Bearing in mind this, we could be vigilant when it happens and take a look in that moment, because I haven't been able to reproduce the error.
I think I found why the command fails, I believe it's when the branch contains a dash '-' in it. I suppose the git command, works as grep, and when it sees a '-' starts to interpret it as an option.
✖ UgO::dragonfly (latest-docker|✔)> grep -in -lOL /tmp/tes
grep: invalid option -- 'O'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
✖ UgO::dragonfly (latest-docker|✔)> grep -in -- -lOL /tmp/test
1:loli-lol
So maybe there is simply a '--' to add to this command to fix it.
It doesn't look that the issue is the -
in the branch name, I tried with a branch whose name has _
and the error was reported anyway
frontend-react ➜ git checkout -b test_dash_1
Switched to a new branch 'test_dash_1'
frontend-react ➜ git push --set-upstream origin test_dash_1
fatal: ambiguous argument 'origin/test_dash_1..HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:cycloidio/youdeploy-frontend.git
* [new branch] test_dash_1 -> test_dash_1
Branch test_dash_1 set up to track remote branch test_dash_1 from origin by rebasing.
However, after I applied your suggested fix on #6 it worked fine, so it solves the issue so far, whatever it is.
Question would be: does the hook still work :D
Yes, it is; the error that I posted before it's before applying your patch, after I applied, it worked.
What I meant was to double check that the hook still verify commits properly about their encryption an all; which I believe wasn't yet done.
I've understood, let me check again
I found the issue.
The issue isn't about the branch name, it happens when the branch doesn't exist in origin at the moment that the hook runs.
That should only happen when the branch is created locally and before the first push; I've checked the hook and if the branch is in origin, then it works, however the current hook doesn't protect of pushing encrypted files in the initial push.
The solution in #6 does not work, it always return an empty list of commits, at least that I got of the cases which I've tested with that change and without it.
Okay, so indeed some extra checks need to be done such as:
I'm getting a new error on the pre-push
hook
.git/hooks/pre-push: 45: .git/hooks/pre-push: Syntax error: redirection unexpected
error: failed to push some refs to 'git@github.com:cycloidio/youdeploy-http-api.git'
my editor detects the same issue when I open the file
I cannot use it anymore, it doesn't work when the remote branch doesn't exist nor exists.
I've got a similar error on the pre-commit.d/pre-commit-ansible-vault
script
.git/hooks/pre-commit.d/pre-commit-ansible-vault: 35: .git/hooks/pre-commit.d/pre-commit-ansible-vault: Syntax error: redirection unexpected
Haven't had the time to dig into the problem yet, but sometimes face the following problem:
The push is being done afterwards, but it means the hook isn't properly executed.