How to add rules.pl

755 views
Skip to first unread message

Clinto Sunny

unread,
Nov 18, 2014, 8:21:14 AM11/18/14
to repo-d...@googlegroups.com
I am new to gerrit and I was trying to configure workflow in gerrit by adding rules.pl as said in the link https://gerrit-review.googlesource.com/Documentation/prolog-cookbook.html#RulesFile . I cloned by remote repository    
after it was cloned I performed
$cd proNa

Then I executed the command
$ git fetch origin refs/meta/config

Then I received the message:
fatal: Couldn't find remote ref refs/meta/config
Unexpected end of command stream

Also I performed

$ git remote add origin "url of my gerrit repository"

$ git pull origin refs/meta/config

I see that the Gerrit repository is a BARE: master which contains only version history and no working files.

When the code mentioned above is executed I see the message:

fatal: C:\Program Files\Git/libexec/git-core\git-pull cannot be used without a working tree.


If someone could help me to add the rules.pl to my gerrit to customize workflow it would be great. I am using Gerrit.2.9.1. 

Bassem Rabil

unread,
Nov 18, 2014, 3:46:02 PM11/18/14
to repo-d...@googlegroups.com
You need to initialize an empty git repository and then pull the refs/meta/config from your Gerrit project, i.e.

% mkdir tmp 
% cd tmp 
% git init 
% git pull ssh://<username>@<Gerrit-URL>:29418/<project-name> refs/meta/config
% vi project.config or git add rules.pl
The above steps initializes an empty git repository and pulls the refs/meta/config from your Gerrit project. After that you can edit the file and modify labels if needed or add rules.pl. And finally commit this change and push it back to the reference refs/meta/config of the project at Gerrit Central.

% git commit project.config or git commit rules.pl
% git push ssh://<username>@<Gerrit-URL>:29418/<project-name> HEAD:refs/meta/config

I hope this helps.

Regards
Bassem

Clinto Sunny

unread,
Nov 19, 2014, 12:13:16 AM11/19/14
to repo-d...@googlegroups.com
When i execute 
% git pull ssh://<username>@<Gerrit-URL>:29418/<project-name> refs/meta/config
I get this message
fatal: Couldn't find remote ref refs/meta/config
Unexpected end of command stream

Matthew Webber

unread,
Nov 19, 2014, 4:09:32 AM11/19/14
to repo-d...@googlegroups.com
There's a command missing in the instructions. Here's what I do:

git init
git remote add origin ssh://<username>@<gerriturl>:29418/<project-name>
git pull origin refs/meta/config
git branch refs/meta/config
git checkout refs/meta/config

David Pursehouse

unread,
Nov 19, 2014, 4:20:49 AM11/19/14
to Clinto Sunny, repo-d...@googlegroups.com
Does your user have Read permission on the refs/meta/config branch?
> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to repo-discuss...@googlegroups.com
> <mailto:repo-discuss...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Clinto Sunny

unread,
Nov 19, 2014, 4:39:02 AM11/19/14
to repo-d...@googlegroups.com, clin...@gmail.com
I installed Gerrit 2.9.1 on my Windows system. I have the server on my system itself. I am learning gerrit and I was trying to configure my work flow. So I think I should have the read permission.

David Pursehouse

unread,
Nov 19, 2014, 4:48:16 AM11/19/14
to Clinto Sunny, repo-d...@googlegroups.com
You can check access on the Web UI:

http://na...@server.com:8080/#/admin/projects/projectName,access

You should see a section named:

Reference: refs/meta/config

and in there, the Read permission should be listed with the groups that
have it.

If it's not there it might be in the parent project. Click on "Rights
Inherit From" at the top, and check the settings on that project.

If you get all the way back up to "All-Projects" without finding it, you
need to add it. Either for the project itself, or one of the parent
projects.

It could also be that, for some reason, there is actually no
refs/meta/config branch. If you do have the Read permission, and it
exists, you should be able to see it in the branch list:

http://na...@server.com:8080/#/admin/projects/projectName,branches

If it doesn't exist, you can try to force it to be created by changing
something in the configuration:

http://na...@server.com:8080/#/admin/projects/projectName

Try to edit the text in the Description field and then press "Save Changes".



On 11/19/2014 06:39 PM, Clinto Sunny wrote:
> I installed Gerrit 2.9.1 on my Windows system. I have the server on my
> system itself. I am learning gerrit and I was trying to configure my
> work flow. So I think I should have the read permission.
>
> On Wednesday, 19 November 2014 14:50:49 UTC+5:30, David Pursehouse wrote:
>
> Does your user have Read permission on the refs/meta/config branch?
>
>
> On 11/18/2014 10:21 PM, Clinto Sunny wrote:
> > I am new to gerrit and I was trying to configure workflow in
> gerrit by
> > adding rules.pl <http://rules.pl> as said in the link
> >
> https://gerrit-review.googlesource.com/Documentation/prolog-cookbook.html#RulesFile
> <https://gerrit-review.googlesource.com/Documentation/prolog-cookbook.html#RulesFile>
> .
> > I cloned by remote repository
> > $ git clone http://na...@server.com:8080/projectName
> <http://na...@server.com:8080/projectName> proNa
> > after it was cloned I performed
> > $cd proNa
> >
> > Then I executed the command
> > $ git fetch origin refs/meta/config
> >
> > Then I received the message:
> > fatal: Couldn't find remote ref refs/meta/config
> > Unexpected end of command stream
> >
> > Also I performed
> >
> > $ git remote add origin "url of my gerrit repository"
> >
> > $ git pull origin refs/meta/config
> >
> > I see that the Gerrit repository is a BARE: master which contains
> only
> > version history and no working files.
> >
> > When the code mentioned above is executed I see the message:
> >
> > fatal: C:\Program Files\Git/libexec/git-core\git-pull cannot be used
> > without a working tree.
> >
> >
> > If someone could help me to add the rules.pl <http://rules.pl> to
> my gerrit to customize
> > workflow it would be great. I am using Gerrit.2.9.1.
> >
> > --
> > --
> > To unsubscribe, email repo-discuss...@googlegroups.com <javascript:>
> > More info at http://groups.google.com/group/repo-discuss?hl=en
> <http://groups.google.com/group/repo-discuss?hl=en>
> >
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Repo and Gerrit Discussion" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to repo-discuss...@googlegroups.com <javascript:>
> > <mailto:repo-discuss...@googlegroups.com <javascript:>>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to repo-discuss...@googlegroups.com
> <mailto:repo-discuss...@googlegroups.com>.

Clinto Sunny

unread,
Nov 19, 2014, 5:40:10 AM11/19/14
to repo-d...@googlegroups.com, clin...@gmail.com
Thank you David. Its solved. Now when I try to push the rules.pl to HEAD:refs/meta/config that is on execution of following command 

 git push ssh://<username>@<Gerrit-URL>:29418/<project-name> HEAD:refs/meta/config

fatal: remote part of refspec is not a valid name in HEAD:/refs/meta/config
Unexpected end of command stream

Could you help me to figure this out also.
>      > <mailto:repo-discuss+unsub...@googlegroups.com <javascript:>>.
>      > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to repo-discuss...@googlegroups.com

David Pursehouse

unread,
Nov 19, 2014, 5:45:35 AM11/19/14
to Clinto Sunny, repo-d...@googlegroups.com
On 11/19/2014 07:40 PM, Clinto Sunny wrote:
> Thank you David. Its solved.

OK, so you mean you can now see the refs/meta/config branch?

> Now when I try to push the rules.pl to
> HEAD:refs/meta/config that is on execution of following command
>
> git push ssh://<username>@<Gerrit-URL>:29418/<project-name>
> HEAD:refs/meta/config
>
> fatal: remote part of refspec is not a valid name in HEAD:/refs/meta/config
> Unexpected end of command stream
>

It looks like you pushed with "HEAD:/refs/meta/config" i.e. with an
extra slash after "HEAD:".

Clinto Sunny

unread,
Nov 19, 2014, 6:06:22 AM11/19/14
to repo-d...@googlegroups.com, clin...@gmail.com
Yeah David. I corrected that. I have used HTTP for push and pull. Now what I see is 

Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 599 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done
To http://clinto@localhost:8080/newProject
 ! [remote rejected] HEAD -> refs/meta/config (prohibited by Gerrit)
error: failed to push some refs to 'http://clin...@sbskkwsvm305.suntecsbs.com:8
080/newProject'

Could you help me how to make the Gerrit accept my rules.pl. How should be the my Access for projects be configured for refs/meta/config so that it accepts rules.pl

David Pursehouse

unread,
Nov 19, 2014, 6:14:58 AM11/19/14
to Clinto Sunny, repo-d...@googlegroups.com
On 11/19/2014 08:06 PM, Clinto Sunny wrote:
> Yeah David. I corrected that. I have used HTTP for push and pull. Now
> what I see is
>
> Counting objects: 6, done.
> Delta compression using up to 2 threads.
> Compressing objects: 100% (4/4), done.
> Writing objects: 100% (6/6), 599 bytes | 0 bytes/s, done.
> Total 6 (delta 0), reused 0 (delta 0)
> remote: Processing changes: refs: 1, done
> To http://clinto@localhost:8080/newProject
> ! [remote rejected] HEAD -> refs/meta/config (prohibited by Gerrit)

Make sure you also have the Push permission on refs/meta/config

Or try to push it for review first with:

HEAD:refs/for/refs/meta/config

If you do the latter you'll also need to make sure your user has the
permissions for any labels you have configured, and the Submit permission.



> error: failed to push some refs to
> 'http://clin...@sbskkwsvm305.suntecsbs.com:8
> 080/newProject'
>
> Could you help me how to make the Gerrit accept my rules.pl. How should
> be the my Access for projects be configured for refs/meta/config so that
> it accepts rules.pl
>
> On Wednesday, 19 November 2014 16:15:35 UTC+5:30, David Pursehouse wrote:
>
> On 11/19/2014 07:40 PM, Clinto Sunny wrote:
> > Thank you David. Its solved.
>
> OK, so you mean you can now see the refs/meta/config branch?
>
> > Now when I try to push the rules.pl <http://rules.pl> to

Clinto Sunny

unread,
Nov 19, 2014, 6:32:16 AM11/19/14
to repo-d...@googlegroups.com, clin...@gmail.com
Thank you so much David. This step is done. Now let me try out configuring workflows. Once again Thank you for your great help which was of great use for fresh hands in Gerrit like me. 


On Wednesday, 19 November 2014 16:44:58 UTC+5:30, David Pursehouse wrote:
On 11/19/2014 08:06 PM, Clinto Sunny wrote:
> Yeah David. I corrected that. I have used HTTP for push and pull. Now
> what I see is
>
> Counting objects: 6, done.
> Delta compression using up to 2 threads.
> Compressing objects: 100% (4/4), done.
> Writing objects: 100% (6/6), 599 bytes | 0 bytes/s, done.
> Total 6 (delta 0), reused 0 (delta 0)
> remote: Processing changes: refs: 1, done
> To http://clinto@localhost:8080/newProject
>   ! [remote rejected] HEAD -> refs/meta/config (prohibited by Gerrit)

Make sure you also have the Push permission on refs/meta/config

Or try to push it for review first with:

HEAD:refs/for/refs/meta/config

If you do the latter you'll also need to make sure your user has the
permissions for any labels you have configured, and the Submit permission.



> error: failed to push some refs to

Clinto Sunny

unread,
Nov 19, 2014, 7:59:43 AM11/19/14
to repo-d...@googlegroups.com, clin...@gmail.com
I added my rules.pl file. Then i committed it and pushed. Everything worked fine. The contents of my rules.pl is 

submit_rule(submit(W)) :-
  W = label('Any-Label-Name', ok(_)).

So that I should be able to submit all changes. 
But I am not able to submit.
In the gerrit server log i see the following ERROR.
ERROR com.google.gerrit.server.project.ChangeControl : Submit rule :(user,submit_rule) for change 37 of gerrit-Test output invalid result: submit(label(All-Changes,ok(_199C961))). Reason: A label with the status All-Changes: OK must contain a user.
ERROR com.google.gerrit.server.project.ChangeControl : Submit rule :(user,submit_rule) for change 38 of gerrit-Test output invalid result: submit(label(All-Changes,ok(_C24821))). Reason: A label with the status All-Changes: OK must contain a user.

My rules.pl file is exactly what is said in the gerrit tutorial. Then why do I see this error and it is not working. Could someone kindly help.

Bassem Rabil

unread,
Nov 19, 2014, 8:23:15 AM11/19/14
to repo-d...@googlegroups.com, clin...@gmail.com
It looks like the example provided in the documentation might be broken, you can check this previous discussion [1] to fix your rules.pl. Also you can use test submit rules to verify your rules.pl described here [2].

Clinto Sunny

unread,
Nov 20, 2014, 1:26:31 AM11/20/14
to repo-d...@googlegroups.com, clin...@gmail.com
Thank you Bassem. I could configure some sample work rules in Gerrit. Actually I was referring    http://www.vogella.com/tutorials/Gerrit/article.html#gerritsetup_repository for the setting up gerrit and pushing projects into gerrit from eclipse. But I face some kind of inconsistency when I push into Gerrit my projects in Eclipse. Some issues regarding Change-Id. 
And I have another doubt. In the tutorial I mentioned above I read that First we should push the project to Gerrit and then clone it to a new workspace. This they have said from a developer point. But isn't it possible that we can make changes in the same local repository and push the changes to our Gerrit repository. 
Could someone clarify my doubts.
It would be greatly helpful if someone can provide a good tutorial about this.

Bassem Rabil

unread,
Nov 20, 2014, 7:52:19 AM11/20/14
to repo-d...@googlegroups.com, clin...@gmail.com
I guess you might be missing the commit-msg hook [1] inside your repository. This hook helps to add the change-id to your commit message to be accepted by Gerrit. You can checkout the presentation for EclipseCon 2013 [2], this presentation is focusing on deploying Gerrit Code Review.


Regards
Bassem
Reply all
Reply to author
Forward
Message has been deleted
0 new messages