Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking Issues of one git repository to commits of another repository

Tags:

I have two projects "project-A" and "project-B". The issues are being reported in "project-A" but the actual development is going on in "project-B".

Referring "project-A" in every commit comment is challenging. I am exploring for a better option to link the issues of "project-A" to be linked to "project-B" code commits. A simple ask is if the developer commits with a comment "#23 fixed" in 'project-B', it should be visible in 'project-A's relevant issue comment history.

like image 514
Gana Avatar asked Apr 02 '18 08:04

Gana


People also ask

How do I link an issue to another repo?

In the right sidebar, click Development. Click the repository containing the pull request or branch you want to link to the issue. Click the pull request or branch you want to link to the issue. Click Apply.

How do I link an issue to another GitHub?

To link related issues in the same repository, you can type # followed by part of the issue title and then clicking the issue that you want to link. To communicate responsibility, you can assign issues. If you find yourself frequently typing the same comment, you can use saved replies.

How do I pull a commit from another repo?

In order to get commits from the other repository, You'll need to add the other repository as a remote, then fetch its changes. From there you see the commit and you can cherry-pick it.


1 Answers

1. Transforming git commit messages:

From your workspace

$ cd myrepo
$ vi .git/hooks/commit-msg

Note that this is a client side hook. Now add the following content to it

#!/bin/sh
projecta_issues_link="https:\/\/github.com\/git\/git\/issues\/"

message=`cat $1 | sed "s/projecta/${projecta_issues_link}/g"`
echo ${message} > $1
exit 0

Then make a change to any file, and commit it with the following message:

git commit -m "This fixes projecta#1234"

Your commit message should be transformed to a link now.

2. Applying the client side hook on all repositories:

There's a really well-written answer to that here.

like image 182
Timir Avatar answered Sep 22 '22 12:09

Timir