I'm setting up a Gerrit server for the team. I've used Gerrit in the past, but I've never set one up.
One feature I know I've used in the past is, once I get a CL approved, I can rebase the branch without losing the approval. I assume this is a setting somewhere, but I can't find it.
You need to set the "Submit Type" of the repository (in the repository configuration page) to one of these:
Rebase If Necessary
If the change being submitted is a strict superset of the destination branch, then the branch is fast-forwarded to the change. If not, then the change is automatically rebased and then the branch is fast-forwarded to the change.
When Gerrit tries to do a merge, by default the merge will only succeed if there is no path conflict. A path conflict occurs when the same file has also been changed on the other side of the merge.
Rebase Always
Basically, the same as Rebase If Necessary, but it creates a new patchset even if fast forward is possible AND like Cherry Pick it ensures footers such as Change-Id, Reviewed-On, and others are present in resulting commit that is merged.
Thus, Rebase Always can be considered similar to Cherry Pick, but with the important distinction that Rebase Always does not ignore dependencies.
See more details in the Gerrit documentation here.
I think you are looking for the Copy All Score On Trivial Rebase labels.
The example below is from our project.config. For the Verified label the scores will be copied if there is a Trivial Rebase or a No Code Change patchset added, the No Code Change basically means an updated commit message.
[label "Verified"]
function = MaxWithBlock
value = -1 Fails
value = 0 No score
value = +1 Verified
copyAllScoresIfNoCodeChange = true
copyAllScoresOnTrivialRebase = true
defaultValue = 0
Related
I have two branches say Branch Child and Parent.
Changesets in Branch Child : 200,201,202,203,204(contain .Net and VB codes)
I have merged up from child to parent containing all these changeset and TFS2015 gives me a changeset number for parent Branch as 300.
Now later i decide that changeset number 201,202 is not required for Branch Parent for now(will be used later)
Is there any way to roll back only changes pertaining to 201,202 from Parent Branch?
What i have tried : i tried rolling back the entire change set number 300. I get error message that revert failed due to dependency on other applications. I am not sure why this error is occurring.
Try to use Rollback Command to see whether you can revert the changeset:
tf rollback /changeset:C300
Using gerrit 2.9. I am new to gerrit configuration and am trying to add a Verified label to the All-projects project so that the verified label is shown in the reviews for all projects. The relevant part of the project.config looks like this:
[label "Code-Review"]
function = MaxWithBlock
copyMinScore = true
value = -2 This shall not be merged
value = -1 I would prefer this is not merged as is
value = 0 No score
value = +1 Looks good to me, but someone else must approve
value = +2 Looks good to me, approved
[label "Verified"]
value = -1 Fails
value = 0 No score
value = +1 Verified
I run the following commands:
$ git commit -am "Add verified label"
$ git push -f origin meta/config:meta/config
Now, when I go and try to review a change-set, I see the needs verified line, but I don't see anywhere that I can place it. The screen looks like this:
There is no way for me to set verified on the review.
I had help from this question: Can't find 'Label Verified' permission in gerrit 2.7 but this did not solve the problem.
The problem is that you don't have sufficient permissions to set the Verified label. In Gerrit, all change scoring must be explicitly allowed. If you don't have permissions to set a label, it won't even appear in the Publish view.
To grant users permission to set the Verified label, locate the project you want to affect (or, perhaps more likely, the special All Projects project to have it apply everywhere). On the Access tab, choose Edit. Under refs/heads/*, add a "Label Verified" permission and assign a suitable group. If there's no refs/heads/* reference in the list, add it.
I've checked libgit2sharp v0.15.0 and it seems like there is no method for removing a remote.
Is there any way to do it?
I've checked libgit2sharp v0.15.0 and it seems like there is no method for removing a remote.
That's completely correct. Such a method doesn't exist yet as it's not supported by libgit2 yet.
There's a work in progress (see PR #1199) to implement this. Subscribing to this PR would let you know about it's future progress.
Is there any way to do it?
You can do it by hand this way:
Remove the whole config section that describes the remote to be deleted
Delete from the config every branch (remote, merge) tuple that depends on the remote to be deleted
Delete from .git/refs/remotes/ every remote tracking branch reference
For instance, if you're willing to drop the remote "useless"
Drop this whole section from the config
[remote "useless"]
url = https://github.com/useless/project.git
fetch = +refs/heads/*:refs/remotes/useless/*
Remove remote and merge entries from the two following branches
[branch "vNext"]
remote = useless
merge = refs/heads/vNext
[branch "topic/awesome_feature"]
remote = useless
merge = refs/heads/topic/awesome_feature
Delete the following references
- .git/refs/remotes/useless/vNext
- .git/refs/remotes/useless/topic/awesome_feature
Update
Pull Request #731 just made possible the removal of remotes through the API.
Syntax: repo.Network.Remotes.Remove(remoteName)
Use libgit2sharp, how to calculate ahead or behind metrics. like this page https://github.com/libgit2/libgit2sharp/branches
How to calculate ahead or behind metrics
Each Branch bears a TrackingDetails property. This property exposes AheadBy and BehindBy nullable values (null will be returned when the branch has no upstream configuration or if the upstream branch does not exist).
Those values will represent the number of commits the local branch is ahead/behind compared to the upstream branch (ie. the remote branch being tracked).
This outputs similar results than git status -sb
like this page https://github.com/libgit2/libgit2sharp/branches
This page actually compares each branch of the upstream (ie. the one hosted on GitHub) repository against the current tip of the remote HEAD. This feature (comparing two local branches) is not available in LibGit2Sharp.
Provided you're interested with it, please feel free to open a feature request.
Update
A pull request (see #564) introducing a new method repo.ObjectDatabase.CalculateHistoryDivergence(Commit, Commit) is cooking up.
This will allow the user to determine the ahead-by and behind-by counts, along with the merge-base that's been used to calculate those distances.
For those searching (as of pygit2 v 0.27.4), the API is ahead_behind.
Sample code gist:
import pygit2
repo = pygit2.Repository('your-repo-path')
upstream_head = repo.revparse_single('origin/HEAD')
local_head = repo.revparse_single('HEAD')
diff = repo.ahead_behind(local_head.id, upstream_head.id)
I've been tinkering around, and reading through what little Wiki information that I could find, and looked through tests that I thought may be relevant, however I'm having problems coming up with a working solution for a few things.
Mostly, I'm looking for a way to list commits that have been pushed to the server ahead of your working repository / local commits. I've tried using Fetch, and FetchHeads, but looking through all of the documentation for the Network class doesn't seem to yield anything that I can understand, I guess. Ideally, I'd be interested in seeing something like:
IQueriableCommitLog Repository.Network.GetCommitsAhead
OR
IQueriableCommitLog Repository.Remote.GetCommitsAhead
Then, just use the results like you would in:
IQueriableCommitLog Repository.Commits
Also, perhaps a method like Commit.UpdateTo() for the remote commit.
Am I too far off base for what I'm looking for? Is it possible at this time to perform actions such as this? Is it supported by libgit2?
Mostly, I'm looking for a way to list commits that have been pushed to the server ahead of your working repository / local commits.
A Branch is either local or remote. Local Branches which are tracking other ones expose a TrackedBranch property.
Considering a local branch with a not null TrackedBranch property
Commits that have been performed on this local branch and aren't known from the tracked one.
repo.Commits.QueryBy(new Filter { Since = branch.Tip, Until = branch.TrackedBranch });
Commits that exist in the tracked branch and aren't known from the local one
repo.Commits.QueryBy(new Filter { Since = TrackedBranch, Until = Tip })