Merge lp:~nskaggs/juju-ci-tools/add-version-branch-support into lp:juju-ci-tools

Proposed by Nicholas Skaggs
Status: Merged
Merged at revision: 1426
Proposed branch: lp:~nskaggs/juju-ci-tools/add-version-branch-support
Merge into: lp:juju-ci-tools
Diff against target: 44 lines (+20/-0)
1 file modified
git_gate.py (+20/-0)
To merge this branch: bzr merge lp:~nskaggs/juju-ci-tools/add-version-branch-support
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+295731@code.launchpad.net

Description of the change

Add support for versioned branch from an unversioned repo. This is to support the names + names.v2 repository and similar stories.

http://gopkg.in/juju/names.v2 lives at https://github.com/juju/names/tree/v2, which otherwise clones into 'names', rather than 'names.v2'.

To post a comment you must log in.
1427. By Nicholas Skaggs

use \Z instead of checking length

Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'git_gate.py'
2--- git_gate.py 2015-12-14 16:23:40 +0000
3+++ git_gate.py 2016-05-25 15:18:07 +0000
4@@ -5,6 +5,7 @@
5
6 import argparse
7 import os
8+import re
9 import subprocess
10 import sys
11
12@@ -51,6 +52,8 @@
13 git = SubcommandRunner("git")
14
15 final_project = args.project
16+ if args.project_ref:
17+ final_project = version_dir_from_branch(args.project, args.project_ref)
18 if args.feature_branch:
19 final_project = from_feature_dir(args.project)
20
21@@ -91,6 +94,23 @@
22 go("test", project_ellipsis)
23
24
25+def version_dir_from_branch(directory, branch_name):
26+ """
27+ For branches of repos that are versioned with gopkg.in, we need to
28+ do some special handling, since the test code expects the version to be
29+ appended to the reponame with a ".". However, the version is different
30+ than the base gopkg.in branch. To account for this, we use the convention
31+ that a version branch is named v[0-9], and clone accordingly.
32+
33+ Thus, the branch for gopkg.in/juju/charm.v6 would be from a git repo
34+ named charm, tagged v6, which should end up in
35+ $GOPATH/src/gokpg.in/juju/charm.v6
36+ """
37+ if re.match('[v]\d\Z', branch_name):
38+ return directory + '.' + branch_name
39+ return directory
40+
41+
42 def from_feature_dir(directory):
43 """
44 For feature branches on repos that are versioned with gopkg.in, we need to

Subscribers

People subscribed via source and target branches