Can I ignore the Verified label for a specific branch?

732 views
Skip to first unread message

Matthew Webber

unread,
Jan 11, 2017, 9:09:24 AM1/11/17
to Repo and Gerrit Discussion
I have a project which inherits the standard Code-Review and Verified labels. On one specific branch, I don't need the Verfied label (we don't verify changes there).


label.Label-Name.branch
Label’s applicable scope can be branch specific via configuration. E.g. create a label Video-Qualify on parent project and configure the branch as:
  [label "Video-Qualify"]
      branch = refs/heads/video-1.0/*
      branch = refs/heads/video-1.1/Kino

But that says the branches which the label applies to. I want to specify that branch that the label does _not_ apply to.

Any ideas?

Thanks
Matthew

Saša Živkov

unread,
Jan 11, 2017, 9:27:27 AM1/11/17
to Matthew Webber, Repo and Gerrit Discussion
On Wed, Jan 11, 2017 at 3:09 PM, Matthew Webber <mat...@unsolvable.org> wrote:
I have a project which inherits the standard Code-Review and Verified labels. On one specific branch, I don't need the Verfied label (we don't verify changes there).

Is there a way of achieving this?

The code which checks if a label applies for a branch uses regex matching [1].
I never tried it (and it is also not officially documented) but you could try writing such a regex
which matches all but that one specific branch where it doesn't apply. You probably need
to use a regex with a negative-lookahead in it.

Another way, which is officially documented and probably easier, is to create a submit rule
which removed the Video-Qualify label when change is pushed to the branch where this
label doesn't apply. See [2] for an example and extend it to make use of gerrit:change_branch
predicate.

 

label.Label-Name.branch
Label’s applicable scope can be branch specific via configuration. E.g. create a label Video-Qualify on parent project and configure the branch as:
  [label "Video-Qualify"]
      branch = refs/heads/video-1.0/*
      branch = refs/heads/video-1.1/Kino

But that says the branches which the label applies to. I want to specify that branch that the label does _not_ apply to.

Any ideas? 

Thanks
Matthew

--
--
To unsubscribe, email repo-discuss+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthew Webber

unread,
Jan 12, 2017, 10:15:05 AM1/12/17
to Repo and Gerrit Discussion, mat...@unsolvable.org
Thank you for the suggestions.

I tried the reg-ex first, but that didn't work for me. The Verified was removed from all branches, not just the one I wanted (though I'm sure the regex was correct), and the UI went a bit weird. So I dropped that approach.

I implemented a Prolog rule, based on your suggestion, and that worked well. For future reference, here is my rules.pl:

submit_rule(S) :-
    gerrit:default_submit(X),
    X =.. [submit | Ls],
    remove_verified_category(Ls, R),
    S =.. [submit | R].
remove_verified_category([], []).
remove_verified_category([label('Verified', _) | T], R) :- gerrit:change_branch(B), regex_matches('refs/heads/gda-8\.22.*', B), remove_verified_category(T, R), !.
remove_verified_category([H|T], [H|R]) :- remove_verified_category(T, R).

Thanks!
Matthew

Saša Živkov

unread,
Jan 12, 2017, 10:52:17 AM1/12/17
to Matthew Webber, Repo and Gerrit Discussion
On Thu, Jan 12, 2017 at 4:15 PM, Matthew Webber <mat...@unsolvable.org> wrote:
Thank you for the suggestions.

I tried the reg-ex first, but that didn't work for me. The Verified was removed from all branches, not just the one I wanted (though I'm sure the regex was correct),

Maybe the issue was only with properly escaping the regex in the project.config, a Git style config
which itself "eats" one level of escaping?

 
and the UI went a bit weird. So I dropped that approach.

I implemented a Prolog rule, based on your suggestion, and that worked well. For future reference, here is my rules.pl:

submit_rule(S) :-
    gerrit:default_submit(X),
    X =.. [submit | Ls],
    remove_verified_category(Ls, R),
    S =.. [submit | R].
remove_verified_category([], []).
remove_verified_category([label('Verified', _) | T], R) :- gerrit:change_branch(B), regex_matches('refs/heads/gda-8\.22.*', B), remove_verified_category(T, R), !.
remove_verified_category([H|T], [H|R]) :- remove_verified_category(T, R).

Thanks!
Matthew

Matthew Webber

unread,
Jan 12, 2017, 11:01:10 AM1/12/17
to Repo and Gerrit Discussion, mat...@unsolvable.org
Good point, but it wasn't that, the '\.' was correctly escaped to '\\.'.

My tip to avoid this kind of problem is to add the string by using "git config -f project.config --add ..." and thereafter taking a look at what is in the file itself.
Reply all
Reply to author
Forward
0 new messages