~cjwatson/launchpad-buildd/rename-slave-prep

« back to all changes in this revision

Viewing changes to lpbuildd/target/vcs.py

  • Committer: Colin Watson
  • Date: 2018-06-05 02:08:12 UTC
  • mfrom: (327.3.2 git-path-tags)
  • Revision ID: cjwatson@canonical.com-20180605020812-mm16ta8j42gkssa8
[r=wgrant] Allow checking out a git tag rather than a branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
            if quiet:
76
76
                cmd.append("-q")
77
77
            if self.args.git_path is not None:
78
 
                cmd.extend(["-b", self.args.git_path])
 
78
                git_path = self.args.git_path
 
79
                # "git clone -b" is a bit odd: it takes either branches or
 
80
                # tags, but they must be in their short form, i.e. "master"
 
81
                # rather than "refs/heads/master" and "1.0" rather than
 
82
                # "refs/tags/1.0".  There's thus room for ambiguity if a
 
83
                # repository has a branch and a tag with the same name (the
 
84
                # branch will win), but using tags in the first place is
 
85
                # pretty rare here and a name collision is rarer still.
 
86
                # Launchpad shortens branch names before sending them to us,
 
87
                # but not tag names.
 
88
                if git_path.startswith("refs/tags/"):
 
89
                    git_path = git_path[len("refs/tags/"):]
 
90
                cmd.extend(["-b", git_path])
79
91
            cmd.extend([self.args.git_repository, name])
80
92
            if not self.ssl_verify:
81
93
                env["GIT_SSL_NO_VERIFY"] = "1"