I'm developing a git-hook that runs on pre-push.
It's purpose is to prevent you from pushing the branch, if there are un-pushed git notes.
In order to achieve this, I need to be able to run some logic during the pre-push hook that can detect if there are unpushed refs/notes/commits
.
Unfortunately - I am terrible at git.
I tried this approach here: Check if local git repo is ahead/behind remote
However when I do git merge-base refs/notes/commits origin/refs/notes/commits
git just tells me:
fatal: Not a valid object name origin/refs/notes/commits
Here is my refspec:
[remote "origin"]
url = https://github.com/dazinator/GitHookExperiment.git
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = +refs/notes/*:refs/notes/*
I have added some notes locally with git notes add
so my local repo - I know it has notes that haven't been pushed. I just don't know what git commands to run to detect that fact whilst I am on another branch (the branch currently being pushed).
I am seeking some git
commands that I can run to yield an output that I can parse to give me a definitive Yes or No that the notes branch is behind or not..