Merge lp:~ursinha/launchpad/add-ec2land-rules-orphaned-branches into lp:launchpad
Status: | Rejected | ||||
---|---|---|---|---|---|
Rejected by: | Ursula Junque | ||||
Proposed branch: | lp:~ursinha/launchpad/add-ec2land-rules-orphaned-branches | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
438 lines (+287/-22) 4 files modified
lib/devscripts/autoland.py (+51/-8) lib/devscripts/ec2test/builtins.py (+26/-4) lib/devscripts/tests/test_autoland.py (+207/-1) lib/lp/registry/utilities/salesforce.py (+3/-9) |
||||
To merge this branch: | bzr merge lp:~ursinha/launchpad/add-ec2land-rules-orphaned-branches | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Māris Fogels (community) | Abstain | ||
Jeroen T. Vermeulen (community) | code | Approve | |
Review via email: mp+29255@code.launchpad.net |
Description of the change
= Summary =
This branch is a fix for bug 601995, adding to ec2 land two options: --no-qa and --incr. --no-qa option should add the [no-qa] tag to the commit message, and --incr option should add the [incr] tag. This enforces the QA policy of now allowing fixes to be committed without bugs unless explicitely pointed.
== Proposed fix ==
The implementation is pretty simple. A method checks if the --no-qa or the --incr options are passed to ec2 land, and combined with the bugs found in the mp decides if the merge can continue based on the QA policy:
* If the mp has no linked bugs and no no-qa tag, ec2 land should fail because without bugs and no-qa tag that commit would be an orphaned one.
* If the mp has bugs and the no-qa commit tag, that's ok. The bug #s and the no-qa tag will be added to the commit message. This will be properly parsed and handled by qa-tagger script after the branch landed.
* If the mp has no linked bugs but has the no-qa commit tag, that's ok. The commit will be qa-untestable, therefore not orphaned.
* If the mp has no linked bugs but has the incr commit tag, ec2 land should fail, because bugs are needed when the fix is incremental.
* A commit cannot be no-qa and incr at the same time.
== Tests ==
I've tested the newly created method by adding more tests to test_autoland.py.
./bin/test -vvt devscripts.*
It's not possible to test get_commit_message directly because it all depends on launchpadlib.
== Demo and Q/A ==
I've tested by running the command in a real merge proposal in Launchpad, using the --dry-run option, to check if the commit message is correctly parsed and tagged by ec2 land.
Considering staging is down for some time now, I've tested with this mp: https:/
$ ec2 land https:/
Results should be as following:
* Both --incr and --no-qa at the same time: should error.
* without --no-qa and nor linked bugs: should error.
* with --incr and no linked bugs: should error.
* with --incr and linked bugs: should work.
* with --no-qa and no linked bugs: should work.
* with --no-qa and linked bugs: should work.
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files:
lib/devscript
lib/devscript
lib/devscript
Nice MP, nice branch! Very thorough and clean. I've been seeing too many MPs without mention of design, caveats, QA, lint etc. lately and this one just has it all—plus a good description of what the branch is supposed to do.
Of course I have some notes:
> === modified file 'lib/devscripts /autoland. py' autoland. py 2010-03-05 21:47:29 +0000 autoland. py 2010-07-06 06:19:30 +0000 r(Exception) : Error(Exception ):
> --- lib/devscripts/
> +++ lib/devscripts/
> @@ -12,6 +12,16 @@
> """Raised when we try to get a review message without enough reviewers."""
>
>
> +class MissingBugsErro
> + """Raised when we try to land a mp without 'no-qa' tag and no linked
> + bugs."""
> +
> +
> +class MissingBugsIncr
> + """Raised when we try to land a mp with the 'incr' tag and no linked
> + bugs."""
I don't think it's necessary to say "Raised when." The derivation from Exception and the name it clear already.
You could just say "Merge proposal has no linked bugs and no 'no-qa' tag," and "Merge proposal has the 'incr' tag but no linked bugs." That also gets around the ugly line breaks and the abbreviation "mp."
> class LaunchpadBranch Lander: branch- lander' 'bzr+ssh' , host=host, path='/' + branch.unique_name) message( self, commit_text, testfix=False): message( self, commit_text, testfix=False, no_qa=False,
>
> name = 'launchpad-
> @@ -152,21 +162,49 @@
> # URL. Do it ourselves.
> return URI(scheme=
>
> - def get_commit_
> + def get_commit_
> + incr=False):
That last parameter should be indented to align with the "self" parameter. We do this differently for method definitions than for method invocations.
> """Get the Launchpad-style commit message for a merge proposal.""" clauses( bugs, no_qa, incr) clause( reviews) , clause( bugs), clauses( bugs, no_qa=False, incr=False):
> reviews = self.get_reviews()
> bugs = self.get_bugs()
> + no_qa, incr = check_qa_
> +
> if testfix:
> testfix = '[testfix]'
> else:
> testfix = ''
> - return '%s%s%s %s' % (
> +
> + return '%s%s%s%s%s %s' % (
> testfix,
> get_reviewer_
> get_bugs_
> + no_qa,
> + incr,
> commit_text)
>
>
> +def check_qa_
> + """Check the no-qa and incr clauses."""
Good instinct to separate bits out like this so that they become unit-testable. This is what made me instantly like this branch. One bit that bothers me slightly is that it does two related but different things: check that the two options are appropriate, and compose a commit string fragment for them.
You also end up with get_commit_message doing different things: gather data, delegate the QA-related checking & composing to check_qa_clauses, and composing the rest of the commit string. AIUI it's the data gathering that makes unit-testing hard, and you did the right thing in not letting it sneak into your own function.
A rule of thumb I have for maintainable code is that a function should not mix abstractions. In get_commit_message we have both "fiddle with strings" and "delegate one area of the checking and string-fid...