Merge ~pappacena/launchpad:refactoring-gitrepo-getRefByPath into launchpad:master
Proposed by
Thiago F. Pappacena
Status: | Merged |
---|---|
Approved by: | Thiago F. Pappacena |
Approved revision: | 0f1b057ab34148619352d9fc33cabed2552bd619 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~pappacena/launchpad:refactoring-gitrepo-getRefByPath |
Merge into: | launchpad:master |
Diff against target: |
53 lines (+19/-5) 2 files modified
lib/lp/code/model/gitrepository.py (+7/-5) lib/lp/code/model/tests/test_gitrepository.py (+12/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Colin Watson (community) | Approve | ||
Review via email: mp+383250@code.launchpad.net |
Commit message
Refactoring GitRepository.
To post a comment you must log in.
Given that we only want the results for the first matching path, it would be possible to be more precise by doing a query that compiles down to something along the lines of this (for id == 10, path == 'master'):
SELECT GitRef.* master' )) AS lookup (index, path)
FROM GitRef, (VALUES (0, 'master'), (1, 'refs/heads/
WHERE GitRef.repository = 10 AND GitRef.path = lookup.path
ORDER BY lookup.index
LIMIT 1;
But given that there are always either one or two elements in path, it seems unlikely to be worth very much bother to fine-tune! So feel free to go ahead with your version if you want. I mention it mainly because this sort of approach can be handy in larger cases.