Branch permissions for 'git notes'

tdacox April 10, 2019

Can Bitbucket Server (5.3 currently) protect 'notes' added via 'git notes' ?

 

For tags, we prevent deletion using a branch specifier 'ref/tags/v/*'  (tags starting with 'v')

But for notes, I have tried using 'refs/notes/*' and 'refs/notes/commits' but no luck. Clients can still remove the note and push it to the server. 

We want to prevent deletion of git notes. Maybe a server-side hook is a better way?

1 answer

1 accepted

0 votes
Answer accepted
Craig Drummond
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 12, 2019

Hi Tim,

Are you using a third party plugin or are you just trying to use git push origin refs/notes/* and then creating a pull request to bring the notes into the appropriate branch?

Bitbucket server doesn't currently have support for Git Notes.  There is an open feature request https://jira.atlassian.com/browse/BSERV-5450 but until there is formalized support for Notes it is unlikely that the branch permissions would be able to protect these items.

In my testing without using any type of third party plugin I was able get the note, but never protect it.  Here is the test I performed

In a test repository I added locally a GIt Note to a commit that already existed:

git notes add -m 'Notes testing by Craig' 6a666ef

I can see the note in the Git Log using git show -s 66a666ef

commit 6a666ef6d34b08c713803ef55c8b1c5ae24cd7f0 (HEAD -> master, origin/master)
Merge: 3e7c92b b6749f8
Author: Craig
Date: Fri Apr 12 09:50:46 2019 -0500

Merge pull request #32 in TEST/test from WILLNOTDELETE to master

* commit 'b6749f89f283d84e7b876fd8a82a14654d6bb90c':
amazing

Notes:
Notes testing by Craig

But, a git status does not show any changes

git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

I tried making a different change (added a file), git add, commit, push and still nothing about the note showed in Bitbucket

Finally I tried git push origin refs/notes/* and this actually pushed the notes to Bitbucket


remote:
remote: Create pull request for refs/notes/commits:
remote: http://localhost/stash/projects/TEST/repos/test/compare/commits?sourceBranch=refs/notes/commits
remote:

* [new branch] refs/notes/commits -> refs/notes/commits


When I login to Bitbucket this new branch is not listed in branches, there are no new commits listed in commits, and the source has not changed. 

I was not able to create a Pull Request using the GUI because this branch did not show up in the drop down. 

My dashboard did have a message about the new commit and when I clicked on it, or if I used the URL in the push response I was able to create a pull request to bring that note into my master branch.

When that was merged I was able to see a new file with my git note in the source.  The filename however was the full commit id that I attached the note to.

Screen Shot 2019-04-12 at 10.28.58 AM.png 

Because Bitbucket is masking the /refs/* from the list of branches I don't believe you can protect this branch using branch permissions.  You might be able to create a pre-receive hook to verify that the notes being pushed do not remove or modify an existing note for the same commit. 

Overall I think we need more information about how you are trying to use Git Notes but also understand that until Bitbucket provides native support you may be best served using an App/Plugin that handles git notes. There is one listed in the marketplace Tag Details And Git Notes but it is not supported by the creator, is not Data Center compatible, and you will need to use an older version that support Bitbucket 5.3

 

Cheers,

Craig Drummond

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events