1

To add note with specific namespace, you can do it like this:

git notes --ref=bugzilla add -m 'bug #15' 0385bcc3

But what if I need to specify it something similarly as with tags. Like from now (if not specified otherwise) all commits must have note with namespace task and value of 10? And later if I would change let say from now: every commit should automatically have note with namespace task and value of 11? In other words I would relate all future commits to automatically get same note (if not specified differently). Or make it like tags, and if relate past commits with specific note?

I need this so I would not need to write same note for every commit that has same note (or same metadata)

Is there something similar I can do with notes, or maybe there are some other cool features that can be used in git (not just notes)?

Andrius
  • 19,658
  • 37
  • 143
  • 243
  • Why not just use tags? – kan Dec 08 '15 at 21:11
  • @kan But as I understand you can only use same tag for only one commit. The thing is I want to relate multiple tags with same metadata. Is there any way to achieve it? – Andrius Dec 09 '15 at 07:06
  • You could find commits made after a tag... so in some sense it's inherited, you could use `git describe` to query it. What is a use case for it? Maybe you need to consider some tools? A repo manager? E.g. Gerrit has a `Topic` assigned to changesets. – kan Dec 09 '15 at 16:36
  • @kan I want to integrate git with our ERP system, so developers could specify related task (its id) that commit was made for and time that was spent for commit. And then that data would be sent to ERP system to generate work summaries on specific tasks. Basically I need to attach some additional info to commits, so some custom script would know where and how to push that commit data. – Andrius Dec 09 '15 at 16:41
  • But why do you need multiple commits magically marked? Usually you just use a footer in commit message, "Bug: 34165752", see https://www.mediawiki.org/wiki/Gerrit/Commit_message_guidelines – kan Dec 09 '15 at 16:45
  • Don't forget, that you could merge/cherry-pick/rebase/etc commits and it breaks that notes magic. – kan Dec 09 '15 at 16:46
  • @kan well I don't want to put such info in commit message, like how long it took to complete it or what is our ERP system task ID. It is not relevant in message itself. It is only relevant internally and repo itself might be shared publicly. And the case I want multiple commits magically marked is to avoid writing same task ID for multiple commits. Because usually you work on one task at a time and you do multiple commits for that task. Its like when you switch to other task, only then you switch note that would be attached. – Andrius Dec 09 '15 at 18:08
  • How about a script which would put notes on multiple commits? – kan Dec 09 '15 at 23:08
  • @kan I wonder how to trigger script call just after commit, so that way it could automatically assign `task id` that is specified in script or somewhere outside. Should I use git hooks or something else to accomplish such thing? – Andrius Dec 10 '15 at 04:47
  • Hm... If I were you, I would just do something like `git task-id 12345`. (you just need to drop an executable into `git-core` folder). And make a server-side hook to reject pushes if commits are missing notes, they are invalid, etc. This is better approach, as usually you should allow devs to commit whatever they want, and then just reject pushes to a main repo if they are not following the rules. – kan Dec 10 '15 at 17:10
  • @kan yeah I think something like that would work – Andrius Dec 10 '15 at 19:36

0 Answers0