From the forums: https://discourse.gitea.io/t/associating-existing-issue-with-a-branch/218/2?u=howl
Definitely something I'd love to see. What's required for this? From the issue; there's a mention of needing editing support for branches
I kinda feel its all backwards.. after all my workflow normally has the issue being created first. Then work starting sometime later.. so selecting the branch at the time of creation makes not much sense... I'm assuming originally this was to associate the issue with a release branch, not a bugfix/feature branch?
+1 on @baradhili
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
This is also something I would like to see in a future version
Because I use Gitea a lot, I would also like to see that feature in the future. Maybe naming the branch depending on the issue's headline.
+1
+1
+1
One dirty way around this issue could be to setup triggers in db. I have been testing the following for the past few days in MySQL db with satisfactory results:
CREATE TRIGGER update_issue_ref AFTER INSERT
ON action FOR EACH ROW
BEGIN
SET @op_type=(SELECT op_type FROM action ORDER BY id DESC LIMIT 1);
SET @last_ref=(SELECT ref_name FROM action ORDER BY id DESC LIMIT 1);
SET @last_repoId=(SELECT repo_id FROM action ORDER BY id DESC LIMIT 1);
IF @op_type = 5 THEN
UPDATE issue SET issue.ref=@last_ref WHERE (issue.ref='') AND (@last_ref LIKE CONCAT("%#",issue.index) AND (@last_repoId=repo_id));
END IF;
END;
Every time a new branch has been created, this will update branch name for an issue matching these criteria:
(@last_ref LIKE CONCAT("%#",issue.index)
e.g. branch-to-fix-#5
to be assigned to issue #5
and it has to be created in the same repository (@last_repoId=repo_id))
Obvious limitations (and possible expansions) are:
(issue.ref='')
is removed, branch will be updated every time a branch ending with #<issueID>
has been created.CREATE TRIGGER update_issue_ref AFTER INSERT
ON action FOR EACH ROW
BEGIN
SET @op_type=(SELECT op_type FROM action ORDER BY id DESC LIMIT 1);
SET @last_ref=(SELECT ref_name FROM action ORDER BY id DESC LIMIT 1);
SET @last_repoId=(SELECT repo_id FROM action ORDER BY id DESC LIMIT 1);
IF @op_type = 5 THEN
UPDATE issue SET issue.ref=@last_ref WHERE (issue.ref='') AND (@last_ref LIKE CONCAT("%#",issue.index) AND (@last_repoId=repo_id));
ELSEIF @op_type = 17 THEN
UPDATE issue SET issue.ref='' WHERE (@last_ref LIKE CONCAT("%#",issue.index) AND (@last_repoId=repo_id));
END IF;
END;
However, beware of https://github.com/go-gitea/gitea/pull/9003: if you use this method, having # in a branch name will break the link. Perhaps use a different convention that does not require escaping characters - maybe start with issue id followed by '--' (@last_ref LIKE CONCAT(issue.index,"--")
Most helpful comment
I kinda feel its all backwards.. after all my workflow normally has the issue being created first. Then work starting sometime later.. so selecting the branch at the time of creation makes not much sense... I'm assuming originally this was to associate the issue with a release branch, not a bugfix/feature branch?