Gitlab: automatically close issue via commit not working - gitlab

in my new project I can't close Gitlab issue's automatically via commit. this is what I try to do:
git add .
git commit -m "close #32"
git push origin develop
in my previous project when I try this codes, issue closed automatically in Gitlab.
what should I do?

First, make sure the commit closing the issue is not the very first commit.
As documented in gitlab-org/gitlab-foss issue 54722, it would not work. By design.
Check if another new commit, with the same comment, works better.
If not, check the GitLab server log for any error mentioning a failure to process the commit comments.

Possibly the feature is disabled from GitLab for certain reason.
Go to GitLab -> Your Project -> Settings -> Repository and see the below screenshot. As seen, the checkbox needs to be enabled in order to avail the auto close functionality based on the reference in the commit message.

Related

Adding Git Commit Message to Commit Reference Link in GitLab Issue Note

We recently migrated from using Subversion and Trac to Git and GitLab. We successfully migrated all of our old data.
I'm still trying to learn GitLab and generally like it better than Trac, but one thing I don't like as much is that when you reference a GitLab Issue in the git commit, it adds a reference and link to that commit under the issue, but you have to browse to the commit itself to see the associated Git commit message.
In Trac, we had it configured such that the Subversion commit messages were all displayed in the Trac ticket with the commit link, so it was easier to view all the relevant information for that ticket in one place.
Is there a way to configure GitLab to display the Git commit message with the Git commit link that shows up under Issues? The message does show up in the commit list, but not on a referenced Issue.
I thought about trying to use a server hook to generate a note with the Git commit message when a commit is made, but just wondering if there is an easier/better way to accomplish this?
There is no built-in way to show the commit message of a crosslinked commit in the issue log. After all, commits are handled the same way as any other mentions: in the issue's history/mention log.
While the example in GitLab's documentation unfortunately misses the opportunity to show an example of a mention in the commit, here's an issue from GitLab itself with a mention. This commit also shows how mentions often get used within commits—with keywords:
Merge branch '65375-broken-master-gitlab-svg-path-test-failing' into 'master'
Update failing jest snapshot
Closes #13186
See merge request gitlab-org/gitlab-ee!14933
These kind of commits close the specific issue and don't require any further user action. Adding that kind of noise to the discussion/comment section of an issue is, in my opinion, only cluttering the discussion between actual humans*. However, the commit still shows up in the log and is clickable and hoverable.
To get back to your question:
Is there a way to configure GitLab to display the Git commit message with the Git commit link that shows up under Issues?
If you hover over the linked commit, then you'll get the commit's subject. There's nothing more that can be achieved within GitLab itself.
I thought about trying to use a server hook to generate a note with the Git commit message when a commit is made, but just wondering if there is an easier/better way to accomplish this?
If you follow the usual commit/merge message based issue closing and use [Closes?|Fix(es)?] #issue in your commit message, you may end up with more noise in the comments than you would like too.
* well, except for some bots

Commit message with Redmine Ticket

I would like to integrate Redmine with SVN in a manner that the commit message automatically gets posted in the Redmine Ticket ID. Kindly let me know if there are any plugins or hooks up which can be used for me to achieve the same
Such functionality is built in.
Go to Admin | Settings click on Repositories tab, and there you will see following section:
Referencing and fixing issues in commit messages
Referencing keywords
By default, there are:
refs,references,IssueID
So when you perform svn commit, and say
refs #23
such change will be displayed on issue no=23, once you refresh repositories and visit issue again.
There is also way to automate it, so svn or git, post-commit hook refreshes repositores for you...
Full doc here: http://www.redmine.org/projects/redmine/wiki/HowTo_setup_automatic_refresh_of_repositories_in_Redmine_on_commit
Such way if you track changes, you can see all code that was changed, regarding some issue...
For example:
And you can click on (diff) to see that particular code...
Then, furthermore, you can copy URL's when you click diff, so you can discuss code with your peers...
Cheers :)

Bluej is not pushing changes to gitlab repository

another little issue with my current choice of IDE , Bluej. I have set it up to be able to share a project (namely to commit and push changes) using GIT,and specifically through a gitlab repository.
After the first couple of successful pushes and commits(two weeks ago), I changed some code today, tried to do exactly the same procedure, and alas, the button OK in bluej to actually push the changes, is not active!
I have checked connection by entering password, all looks fine. Also, commits are happening fine locally, but when I try to push them through the TeamWorks of Bluej, the OK button remains inactive.
ps: a restart of the program did not solve the issue.
In that case:
switch to the command-line,
go to your repository folder,
and do a git fetch + git status
That should show you why a simple git push is not possible (possibly because you need to pull first)

Creating a branch from issue in GitLab

I've just started using GitLab, and have created a set of issues, in order to keep an overview of what needs to be done for my application. I was wondering if it was possible to create a branch from these issues, such that the branch and issues are linked, similar as in jira and Stash from atlassian?
If you create a branch with the name <issue-number>-issue-description and push that branch to gitlab, it will automatically be linked to that issue. For instance, if you have an issue with id 654 and you create a branch with name 654-some-feature and push it to gitlab, it will be linked to issue 654.
Gitlab will even ask you if you want to create a merge request and will automatically add Closes #654 to the merge request description which will close issue 654 when the merge request is accepted.
Also if you go to a given issue page on gitlab, you should see a New Branch button which will automatically create a branch with a name of the form <issue-number>-issue-description.
On the Issue screen, you see a green button labeled "Create merge request", with a down-arrow to its right.
That's not a button, that's a drop down list of buttons.
Click on the down arrow
Choose "Create branch"
Click on "Create branch"
A branch is created from the issue number, plus the title of the branch
For example, my issue #2, with title "Test repoSearch with no repos"
will have a branch called:
2-test-reposearch-with-no-repos
Notice that it changes case to all-lower-case
TLDR: do a merge request add #2 in the title and/or in the comment box and/or the commit message and it will link the issue to the branch and commit, you could just do a MR right from the start to link it.
It seems the only option for Gitlab is name your branch following this format: <issue-number-some-branch> like 2-bad-ai this will autolink the branch to the issue.
However, I organize my branches so they live nicely in the .git/ref/heads folder structure like this feature/2-<some-branch> then when you do a merge request add #2 in the title and/or in the comment box and/or the commit message and it will link the issue to the branch and commit, you could just do a MR right from the start to link it.
$ ls .git/refs/heads/; ls .git/refs/remotes/upstream/
2-bad-ai dev feature/ hotfix/ master release/
2-bad-ai dev feature/ hotfix/ master release/
I'd much rather have feature/2-bad-ai in the above output...
From what I can tell on Github you can link pull-request to feature/2-<some-branch> but doesn't have the autolinking of 2-<some-branch> like GitLab
2017:
If you create a branch with the name -issue-description and push that branch to GitLab, it will automatically be linked to that issue.
This is now customizable, with GitLab 15.6 (November 2022):
Configure default names for branches created from issues
Define a custom template for naming branches created from issues. The previous setting {issue ID}-{issue-title-hyphenated} remains the default.
To define a custom template for your project, go to Repository Settings > Branch defaults.
See Documentation and Issue.

Set Specific alerts on SVN commit with Tortoise

I noticed that in my developpment team, sometimes someone forgets to commit a file that must go with an other to keep the site working. this causes problemes and waste of time...
The question is : Is it possible to tell SVN tortoise : if someone tries to commit a file A without files (A1, A2,...An) ask them if they are sure they don't need to commit them too?
You need to have look at hooks.hook is nothing but a program triggered by some repository event.You can write whatever set of activities(alert in your case) inside hooks.use pre hooks for running the hooks before any task take place.
EDIT:
Refer commit monitor.CommitMonitor is a small tool to monitor Apache™ Subversion® repositories for new commits.

Resources