About adding custom criteria in gerrit - gerrit

We using gerrit code review tool for code review and verification. Gerrit internally allow to submit code on two criteria 1.Code-Review(-2,-1,0,+1,+2) and 2.Verified(-1,0,+1). I have to add other one my custom criteria to allow submit the code.So how can i achieve this thing.

The Gerrit labels (Code-Review and Verified) are defined in the project.config file of the All-Projects project. Administrators and project owners can define their own labels or customize existing labels by changing the project.config file from the All-Projects project or any other project.
See all information about customized labels on Gerrit documentation.
To change a project.config file do the following:
1) Clone the project (ex: All-Projects)
git clone https://USER#GERRIT-SERVER/a/All-Projects
2) Fetch and checkout the refs/meta/config branch
git fetch refs/meta/config
git checkout FETCH_HEAD
3) Edit the project.config file
EDITOR project.config
4) Add, commit and push to Gerrit
git add project.config
git commit
git push origin HEAD:refs/meta/config
You can also edit the project.config file using the GUI:
Projects > List > SELECT-THE-PROJECT > General > Edit Config

Related

How to add file to repo from Bitbucket Server like GitHub

I am on version v6.6.3 of Atlassian Bitbucket Server:
From the GitHub website, I can freely add new files and edit existing files without needing to clone / push. In Bitbucket, I can freely edit any existing file by clicking on the file in the "Source" tab, but there does not seem to be any option to add new files.
Is there a way to add a new file to a repository in Bitbucket without needing to clone / push anything?
Is there an equivalent to the "Create new file" button from GitHub in Bitbucket?
Here is what my repo view looks like in Bitbucket Server:
Bitbucket Cloud (v.7.1) provides the Add file option in every page level under the project source:
It will be added as a new commit.

How to clone a Gerrit Code Review repository to a local repository

I have installed Gerrit Code Review. Everything is working fine but in the documentation it is unclear how to clone a repository to local directory.
Using Gerrit admin interface I created a new project. How do I know what URL to use? Does Gerrit support https access to repositories?
Go to Gerrit Web UI
Go to the "Projects > List" menu item
Find your project (use the "Filter" field if needed)
Click on the project name
Go to the "General" tab
See the "git clone" command on the top of the page
Choose if you want to clone via "http" or "ssh"
Copy the "git clone" command clicking on the right icon
Paste/execute the "git clone" command
As it turns out this issue is related to SSH/HTTP/Anonymous HTTP Clone URL not visible in Gerrit 2.12.2
I installed in batch mode without plugins. In that case git clone is not there.

Integrate Projects in a single project

I have same xcode project on two deferent macbooks with different code.we need to merge that code but we are not using any git account.We need to merge same file as well,I mean we have same viewcontroller and added two people add a code in single view controller How i can merge it.
For example:
I have a view controller Name "XYZ"and Person 1 added "Login Method"
into "XYZ" and person 2 added "Sign up Method" into XYZ. and both code
are on deferent macbook without any git account how I can merge
that.
Since you use the git tag, I will provide the way to do version control by git.
First, please sign up account for bitbucket (free for private repository) or github (only free for public repository). And create a repository. They are as the remote git repository(repo).
Then use git bash for local repository.
In one macbook, use these steps:
git clone <URL for your bitbucket or github repo>
cd reponame
copy your xcode project in reponame folder
git add .
git commit -am 'code version from first macbook'
git push
Now the code in the first macbook is pushed in your remote repo.
In the other macbook, use these steps:
In an empty folder, use git init
copy your xcode project in this folder
git add .
git commit -am 'code version from second macbook'
git remote add origin <URL for your bitbucket or github repo>
git pull origin master
Now the code from macbook1 is merging in macbook2
If there has conflict files, you should check and save them, and then use git add . and git commit -m 'solve merge conflict'.
Now this is the version that you merge the different macbooks together. You can push the version in remote repo by git push.
More git related, you can refer git book.
Any version control system comes to handy in this kind of situations. Merging manually is the option available other than version control system. Either merge using version control system like git or manually merge the files which is very hard to workout.

Disable edit feature in gerrit change

I am recently using Gerrit and starting to play with different features. I figure out that editing a change may cause some issues like following :
After submitting the edited change, the commiter get a conflict when pulling the remote.
On my machine, gerrit changes some character encode. It increase the number of line changed.
The question is : Is it possible to disable the edit feature in Gerrit ?
I didn't find the feature in access configuration of Project All-Projects
Gerrit does not have this feature at present. Since it's free and open source, you could modify its source code to disable the edit button. There is another edit entry on the side-by-side diff view.
The committer must abandon the previous commit in the local since it's not merged into the remote branch, and reset the local HEAD to the new patch-set/commit before next git pull, via commands like
git fetch origin refs/changes/zz/xxxzz/y && git reset FETCH_HEAD --hard
or
git fetch origin <branch> && git checkout -b <branch> FETCH_HEAD
As to your 2nd problem, I think there is some config about encoding or crlf.

Edit project.config in a Gerrit project

I want to add a "verified" label to my Gerrit project to allow Jenkins to verify that the code builds and passes its tests and so on.
I know I need to add a section to project.config as below:
[label "Verified"]
function = MaxWithBlock
value = -1 Fails
value = 0 No score
value = +1 Verified
However, how do I get to that file to edit it?
The project settings are kept in the Git repository for the project. You can edit them by cloning the project from Gerrit, making the change, committing and pushing back to Gerrit.
You can do this for any project, but if you want it to be inherited by all your projects, which you probably do, use All-Projects as the project.
mkdir gtproj
cd gtproj
git init
git remote add origin ssh://<USER>#<GERRITHOST>:29418/<PROJECT>
git fetch origin refs/meta/config:refs/remotes/origin/meta/config
git checkout meta/config
Then, make the change to the project.config file which will now be in the current directory.
Now, commit the change, and push back to the Gerrit repo:
git commit -a -m "Added label - Verified"
git push origin meta/config:meta/config
And that's it.
If you want to test it: assuming you were actually adding the Verified label, you can check it is working like this. First, make sure the refs/heads/* section of All-Projects (or whichever project you changed above) has Label-Verified -1/+1 set for the relevant groups. This allows the listed groups to verify.
Now, assuming you have a project called MyProject and a patchset reference, say 1,1, to verify:
ssh -p 29418 user#host gerrit review --project MyProject --message "'I just verified this patchset'" --verified +1 1,1
This should return more or less immediately. You should now see in the Gerrit web UI that the user you just logged in as over SSH has left a +1 verified review on that patch.
Credit: Cribbed from this blog post.
You can configure your project config in the Gerrit UI.
You should follow the following steps:
Launch your Gerrit UI.
Login as admin.
Go to projects > and
click List.
Select your project and click Edit config button.
Paste your content and click save.

Resources