示例#1
0
 def parse_branches(self, data):
     """
     Parse output of git branch -r, eg:
           origin/2.0.X
           origin/HEAD -> origin/master
           origin/develop
           origin/master
           origin/release/2.0.0
           origin/release/2.1.0
     """
     clean_branches = []
     raw_branches = csv.reader(StringIO(data), delimiter=' ')
     for branch in raw_branches:
         branch = filter(lambda f: f != '' and f != '*', branch)
         # Handle empty branches
         if len(branch):
             branch = branch[0]
             if branch.startswith('origin/'):
                 cut_len = len('origin/')
                 slug = branch[cut_len:].replace('/', '-')
                 if slug in ['HEAD', self.fallback_branch]:
                     continue
                 clean_branches.append(VCSVersion(self, branch, slug))
             else:
                 # Believe this is dead code.
                 slug = branch.replace('/', '-')
                 clean_branches.append(VCSVersion(self, branch, slug))
     return clean_branches
示例#2
0
 def _parse_branches(self, data):
     """
     Parse output of git branch -a, eg:
           develop
           master
         * release/2.0.0
           rtd-jonas
           remotes/origin/2.0.X
           remotes/origin/HEAD -> origin/master
           remotes/origin/develop
           remotes/origin/master
           remotes/origin/release/2.0.0
           remotes/origin/release/2.1.0
     """
     raw_branches = [bit[2:] for bit in data.split('\n') if bit.strip()]
     clean_branches = []
     for branch in raw_branches:
         if branch.startswith('remotes/'):
             if branch.startswith('remotes/origin/'):
                 real_branch = branch.split(' ')[0]
                 slug = real_branch[15:].replace('/', '-')
                 if slug in ['HEAD', self.fallback_branch]:
                     continue
                 clean_branches.append(VCSVersion(self, real_branch, slug))
         else:
             clean_branches.append(VCSVersion(self, branch, branch))
     return clean_branches
示例#3
0
 def parse_branches(self, data):
     """
     Parse output of git branch -a, eg:
           develop
           master
         * release/2.0.0
           rtd-jonas
           remotes/origin/2.0.X
           remotes/origin/HEAD -> origin/master
           remotes/origin/develop
           remotes/origin/master
           remotes/origin/release/2.0.0
           remotes/origin/release/2.1.0
     """
     clean_branches = []
     raw_branches = csv.reader(StringIO(data), delimiter=' ')
     for branch in raw_branches:
         branch = filter(lambda f: f != '' and f != '*', branch)
         branch = branch[0]
         if branch.startswith('remotes/origin/'):
             slug = branch[15:].replace('/', '-')
             if slug in ['HEAD', self.fallback_branch]:
                 continue
             clean_branches.append(VCSVersion(self, branch, slug))
         else:
             slug = branch.replace('/', '-')
             clean_branches.append(VCSVersion(self, branch, slug))
     return clean_branches
示例#4
0
    def parse_tags(self, data):
        """
        Parses output of bzr tags, eg:

            0.1.0                171
            0.1.1                173
            0.1.2                174
            0.2.0-pre-alpha      177

        Can't forget about poorly formatted tags or tags that lack revisions,
        such as:

            3.3.0-rc1            ?
            tag with spaces      123
        """
        # parse the lines into a list of tuples (commit-hash, tag ref name)
        squashed_data = re.sub(r' +', ' ', data)
        raw_tags = csv.reader(StringIO(squashed_data), delimiter=' ')
        vcs_tags = []
        for row in raw_tags:
            name = ' '.join(row[:-1])
            commit = row[-1]
            if commit != '?':
                vcs_tags.append(VCSVersion(self, commit, name))
        return vcs_tags
示例#5
0
    def parse_tags(self, data):
        """
        Parses output of show-ref --tags, eg:

            3b32886c8d3cb815df3793b3937b2e91d0fb00f1 refs/tags/2.0.0
            bd533a768ff661991a689d3758fcfe72f455435d refs/tags/2.0.1
            c0288a17899b2c6818f74e3a90b77e2a1779f96a refs/tags/2.0.2
            a63a2de628a3ce89034b7d1a5ca5e8159534eef0 refs/tags/2.1.0.beta2
            c7fc3d16ed9dc0b19f0d27583ca661a64562d21e refs/tags/2.1.0.rc1
            edc0a2d02a0cc8eae8b67a3a275f65cd126c05b1 refs/tags/2.1.0.rc2

        Into VCSTag objects with the tag name as verbose_name and the commit
        hash as identifier.
        """
        # parse the lines into a list of tuples (commit-hash, tag ref name)
        raw_tags = csv.reader(StringIO(data), delimiter=' ')
        vcs_tags = []
        for row in raw_tags:
            row = filter(lambda f: f != '', row)
            if row == []:
                continue
            commit_hash, name = row
            clean_name = name.split('/')[-1]
            vcs_tags.append(VCSVersion(self, commit_hash, clean_name))
        return vcs_tags
示例#6
0
    def parse_tags(self, data):
        """
        Parses output of `hg tags`, eg:

            tip                              278:c4b2d21db51a
            0.2.2                            152:6b0364d98837
            0.2.1                            117:a14b7b6ffa03
            0.1                               50:30c2c6b3a055
            maintenance release 1             10:f83c32fe8126

        Into VCSVersion objects with the tag name as verbose_name and the
        commit hash as identifier.
        """
        vcs_tags = []
        tag_lines = [line.strip() for line in data.splitlines()]
        # starting from the rhs of each line, split a single value (changeset)
        # off at whitespace; the tag name is the string to the left of that
        tag_pairs = [line.rsplit(None, 1) for line in tag_lines]
        for row in tag_pairs:
            if len(row) != 2:
                continue
            name, commit = row
            if name == 'tip':
                continue
            revision, commit_hash = commit.split(':')
            vcs_tags.append(VCSVersion(self, commit_hash, name))
        return vcs_tags
示例#7
0
    def parse_tags(self, labels):
        vcs_tags = []

        for label in labels:
            label_name = label['label']
            vcs_tags.append(VCSVersion(self, '@' + label_name, label_name))

        return vcs_tags
示例#8
0
    def parse_branches(self, data):
        """
        stable
        default
        """

        names = [name.lstrip() for name in data.splitlines()]
        return [VCSVersion(self, name, name) for name in names if name]
    def branches(self):
        branches = []
        proj = self.get_project()

        for series in proj.series:
            branches.append(
                VCSVersion(self, series.branch.bzr_identity, series.name))

        return branches
示例#10
0
 def parse_branches(self, data):
     """
     stable                     13575:8e94a1b4e9a4
     default                    13572:1bb2a56a9d73
     """
     raw_branches = csv.reader(StringIO(data), delimiter=' ')
     clean_branches = []
     for branch in raw_branches:
         branch = filter(lambda f: f != '', branch)
         if branch == []:
             continue
         name, rev = branch
         clean_branches.append(VCSVersion(self, name, name))
     return clean_branches
示例#11
0
    def parse_tags(self, data):
        """
        Parses output of show-ref --tags, eg:

            0.1.0                171
            0.1.1                173
            0.1.2                174
            0.2.0-pre-alpha      177
        """
        # parse the lines into a list of tuples (commit-hash, tag ref name)
        raw_tags = csv.reader(StringIO(data), delimiter=' ')
        vcs_tags = []
        for name, commit in raw_tags:
            vcs_tags.append(VCSVersion(self, commit, name))
        return vcs_tags
示例#12
0
    def _parse_tags(self, data):
        """
        Parses output of svn list, eg:

            release-1.1/
            release-1.2/
            release-1.3/
            release-1.4/
            release-1.4.1/
            release-1.5/
        """
        # parse the lines into a list of tuples (commit-hash, tag ref name)
        raw_tags = [line.rstrip('/') for line in data.strip('\n').split('\n')]
        vcs_tags = []
        for name in raw_tags:
            vcs_tags.append(VCSVersion(self, '/tags/%s/' % name, name))
        return vcs_tags
示例#13
0
    def _parse_tags(self, data):
        """
        Parses output of show-ref --tags, eg:

            0.1.0                171
            0.1.1                173
            0.1.2                174
            0.2.0-pre-alpha      177
        """
        # parse the lines into a list of tuples (commit-hash, tag ref name)
        raw_tags = [
            line.rsplit(' ', 1) for line in data.strip('\n').split('\n')
        ]
        vcs_tags = []
        for name, commit in raw_tags:
            clean_name = name.strip(' ')
            vcs_tags.append(VCSVersion(self, commit, clean_name))
        return vcs_tags
示例#14
0
    def parse_tags(self, data):
        """
        Parses output of svn list, eg:

            release-1.1/
            release-1.2/
            release-1.3/
            release-1.4/
            release-1.4.1/
            release-1.5/
        """
        # parse the lines into a list of tuples (commit-hash, tag ref name)

        raw_tags = csv.reader(StringIO(data), delimiter='/')
        vcs_tags = []
        for name, _ in raw_tags:
            vcs_tags.append(VCSVersion(self, '/tags/%s/' % name, name))
        return vcs_tags
示例#15
0
    def _parse_tags(self, data):
        """
        Parses output of show-ref --tags, eg:

        tip                              278:c4b2d21db51a
        0.2.2                            152:6b0364d98837
        0.2.1                            117:a14b7b6ffa03
        0.1                               50:30c2c6b3a055
        """
        # parse the lines into a list of tuples (commit-hash, tag ref name)
        raw_tags = [line.rsplit(' ', 1) for line in data.strip('\n').split('\n')]
        vcs_tags = []
        for name, commit in raw_tags:
            clean_name = name.strip(' ')
            if clean_name == 'tip':
                continue
            commit_hash = commit.split(':')[1]
            vcs_tags.append(VCSVersion(self, commit_hash, clean_name))
        return vcs_tags
示例#16
0
    def _parse_tags(self, data):
        """
        Parses output of show-ref --tags, eg:

            3b32886c8d3cb815df3793b3937b2e91d0fb00f1 refs/tags/2.0.0
            bd533a768ff661991a689d3758fcfe72f455435d refs/tags/2.0.1
            c0288a17899b2c6818f74e3a90b77e2a1779f96a refs/tags/2.0.2
            a63a2de628a3ce89034b7d1a5ca5e8159534eef0 refs/tags/2.1.0.beta2
            c7fc3d16ed9dc0b19f0d27583ca661a64562d21e refs/tags/2.1.0.rc1
            edc0a2d02a0cc8eae8b67a3a275f65cd126c05b1 refs/tags/2.1.0.rc2

        Into VCSTag objects with the tag name as verbose_name and the commit
        hash as identifier.
        """
        # parse the lines into a list of tuples (commit-hash, tag ref name)
        raw_tags = [line.split(' ', 1) for line in data.strip('\n').split('\n')]
        vcs_tags = []
        for commit_hash, name in raw_tags:
            clean_name = self._get_clean_tag_name(name)
            vcs_tags.append(VCSVersion(self, commit_hash, clean_name))
        return vcs_tags
示例#17
0
    def parse_tags(self, data):
        """
        Parses output of show-ref --tags, eg:

        tip                              278:c4b2d21db51a
        0.2.2                            152:6b0364d98837
        0.2.1                            117:a14b7b6ffa03
        0.1                               50:30c2c6b3a055
        """
        # parse the lines into a list of tuples (commit-hash, tag ref name)
        raw_tags = csv.reader(StringIO(data), delimiter=' ')
        vcs_tags = []
        for row in raw_tags:
            row = filter(lambda f: f != '', row)
            if row == []:
                continue
            name, commit = row
            if name == 'tip':
                continue
            revision, commit_hash = commit.split(':')
            vcs_tags.append(VCSVersion(self, commit_hash, name))
        return vcs_tags