While doing some branch maintenance today, I lost a MR and the associated discussion. Not a tragedy but I'd like to get it back if possible. I found an open GitLab enhancement request to undo branch delete but that doesn't quite seem to be what I want. Here's what happened:
Branch A was pushed to our local installation of GitLab, an MR created, and some discussion ensued. We realized that A was a good start but we needed some significant refactoring. We hoped to keep the branch name for the work we'd ultimately merge/ship so we:
Created A-prime on the local system and pushed it to GitLab
Deleted A, hoping that the MR would be associated with the commits, not the branch. But when we deleted A, the MR was no longer accessible.
Recreated A at the same commit as it had been and pushed it to GitLab hoping the MR was hanging out and would get reassociated.
Clearly our mental model of GitLab is wrong. It seems that a post-commit hook or something deletes MRs as a branch is deleted. My question now is: can I get the deleted MR and its discussion back?
I apologize for wasting the communities time. I'm a GitLab newbie and was stumbling around. I didn't stumble far enough. Today we discovered that you can get to the original MR if you have the URL. When you get there, it's Closed, as you'd expect, I suppose. If you go back to the project level and navigate to MRs, then pick the Closed tab, it's there. It likely was there all along but in our panic and newbiness, we didn't find it.
Deleted A, hoping that the MR would be associated with the commits, not the branch.
That is not indeed how a MR is managed.
I prefer creating a new MR, with as a first comment a link to the previous one, and a summary of the state of the discussion.
However, it does not seem to be possible to rename the branch associated with the MR (issue 32952): this is part of a larger discussion at GitLab, still in progress.
In the meantime, try and contact GitLab support to ask them to restore your old branch (and hopefully its MR)
Related
I would appreciate any help to find a way to make it impossible for any single person to make changes to the master branch of a Github repository without having that change reviewed by another person. Using the usual branch protection rules, I have been unable to see how I can prevent the following scenario:
Person A makes a legitimate PR.
Person B inserts a malicious change to the PR. Then reviews the PR with their own malicious change, and subsequently merges to master.
I have considered raising the number of required reviews from 1->2, but I would prefer another solution.
Any help is greatly appreciated, thank you.
I have a project, based on buildroot, which is composed of two repos:
Buildroot root, let's say project A
Our packages, project B
We host a Gitlab server, and I'd like to set up a CI/CD job for the compilation.
The process I want to set up is as follow:
If a merge request (MR) appears on A/B -> trigger a pipeline.
If two MRs appears on both repos, referring the same issue, in a 15 minutes interval (this timer is to give some time to the developer to create all his MRs for his issue) -> trigger a single pipeline visible for both of the MRs.
The last point is where I struggle. Basically, what I want is to have one unique pipeline for one issue, so that if both repos have a MR for this particular issue, my pipeline would checkout on the correct branch for A and B and then launch the compilation for it.
I know I can trigger a pipeline on repo A from B, but I can't figure out how to ensure a unique pipeline will be launched if two MRs are created. Because right now, from what l can see, each MR would create it's pipeline and I'll end up with two compilations...
I've thought about using buildbot with Gitlab, but I'd prefer to stay on Gitlab only, because it's easier to maintain, than having many different tool for this.
Does anyone have ever faced this kind of problem on Gitlab and/or have a clue on how to deal with it ?
Thanks in advance!
Edit
I've come across this page which appears to be the exact solution to my problem, and unfortunately that seems not to be on the roadmap.
I'll dig into the proposition of having a meta project above A and B, because it would allow me to keep everything with Gitlab-CI, even if it means creating this project and dealing with a special process...
Answering my own question.
I've been trying to build up a setup with buildbot for several days, but as I said I really don't wanna add another tool to manage (my team isn't ready for this, and buildbot does too many things that we don't need for now).
I've come into this comment which made me chose the following approach.
Gitlab.example.com
A B *NEW Project 'C' only for CI/CD*
------\/------ ----------------\/--------------
- Trigger C with Key for the issue X, - Fetch/clone A and B for issue X
unless one already exists for issue X - Prepare the sources
- Wait for C to finish - Compile
- Report C's status (with URL to the
corresponding Pipeline)
This setup is the best I can get for a Gitlab-only solution.
If someone's interested in the code I used, tell me and I'll post sample.
In Gitlab CE, one can filter Merge Requests on Author, Assignee, Milestones and Labels. We cannot find a way to filter the search by Target Branch. Are we missing how this is done, or is that feature not available?
In Github, this is done by entering base:x where x is the branch to filter by under Pull Requests.
Unfortunately, it is not yet possible to filter Merge Requests by the destination branch, although it is an open feature proposal in issue 22135. I apologize that this may not be the answer you were hoping for.
Please feel free to mark your support for the proposal, discuss any ideas, or even submit a merge request if you’d like to do so. You can do any of these from the issue page and I encourage you to lend your voice to the development of this feature.
Yes, here's how!
https://gitlab.com/gitlab-org/cli/-/blob/main/docs/source/mr/list.md
glab mr list --target-branch=trunk
The ability to filter merge requests by target branch is now implemented directly in GitLab via https://gitlab.com/gitlab-org/gitlab-foss/-/issues/33831 since about 2020.
We are investigating a workflow in Perforce where we create a new temporary branch for every feature project. When projects are stable, they're integrated back into our main branch. Down the line, we would like to remove old project branches from the repository. However I believe this will also delete all revision history for the files modified in the branch. Is it possible to integrate the revision history from the project branches into the main branch?
One solution that I've considered is to manually integrate each individual checkin when merging code back into the main branch. This does not seem like the right approach.
The revision histories as stored against the branch they are applied to, so it is not possible to merge from one to the other. Your idea about integrating each changelist from the project branch will work, but is also a pain as you have pointed out.
I've made extensive use of branching over the years and I can't remember a case where we wished we'd had the branch revision history in the main line or even looked at the branch revision history after the branch was merged back into the main line.
You'll have the revision histories available (though not directly) for a while after a merge and (ideally) anything you check in to the main development branch should pass all the unit tests so the chances of it breaking should be minimised.
First of all, why do you want to remove the branches from the repository? Are you noticing having multiple branches to affecting performance (or expecting it to)? For each 'temporary' branch are you taking an entire copy of the main line? Also why do you consider these branches 'temporary', I would argue if they are for a feature then they are not and should be preserved.
A few articles to read:
- P4 KB Sparse Branching
- P4 Blog: Perforce Anti-Patterns Over-Branching
I believe, without knowing more information, that you could: use sparse branching, make these 'temporary' branches permanent, and if you really have a need for a temporary branch create a private working branch for each of your developers.
I tried to merge some work that a developer did in a working branch to a stable branch. The files a, b, and c had been changed by at least a dozen changesets since the common ancestor of STABLE and HEAD branches were separated.
I expected that since this developer changed five lines in each of file a, b, and c, that when I integrated from the HEAD to the STABLE branch, I would get his changes in my pending changset, which I could then review and commit.
Instead, it seems that it has taken every change that happened to file A, since the two were branched, and applied all of those changes that also existed in my colleague's working copy.
In other words, there seems to be no record in a perforce changeset, of what my colleague actually changed, versus what the file before contained.
If I browse the submitted changesets, I can see the difference between my colleague's version of the file, and the immediately preceding version. But then, that does not, it seems, determine what goes into the merge.
Doesn't a changeset mean, "a set of changes made between rev X and revision X+1 of a file"?
Can anybody help me understand what it means to "integrate a changeset" when in fact, what it seems is that Perforce doesn't track changes, it tracks files.
It is entirely possible that I am doing everything wrong, and would appreciate any pointer as to how it is that you can can merge accurately and safely between Perforce working branches and stable branches, without stuff that you don't want to get integrated to the stable branch getting integrated. It seems that no matter how simple the changes that actually get made in the product, the merge does not actually work for me.
Perforce does save changes to text files as deltas (binary files get saved in their entirety every time a change is submitted). It sounds like you're not properly restricting the revision range during your integration.
You say the working branch has "...been changed by at least a dozen changesets since the ...branches were separated." Let's call them changelists 1-12. If I understand you correctly you are trying to integrate the modifications made in just one of those changelists, not all of them.
During a simple integration operation Perforce will assume you want to integrate all of the changes that have been submitted since the branch was made. If you only want a subset of these changes, you have to specify a revision range. So, if you just want to integrate the changes that occurred between changelist 11 and 12, you would specify that revision range as shown in the screen capture. (Note: the revision range is inclusive, so specifying a range of 11-12, as I do in this screen shot will actually include changes in changelists 11 and 12. If you just want to integrate the changes made in changelist 12, enter 12 in both fields of the revision range.)
Just be aware that the inevitable conflicts that arise may be difficult to resolve, depending upon how far the branches have diverged and the nature of the changes.
Could you be more specific on how you did the integration? My guess is that you probably have integrated all the changes up to that changelist instead of just that changelist only. If so all you need to do is to specify the same changelist as both the upper and lower limit of the integration.
It's very easy to do in the visual client, but I'm not sure of the exact command line switch you need to use.