Python get git tag
11 Python code examples are found related to "
get git tag".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: git_utils.py From dagster with Apache License 2.0 | 8 votes |
def get_most_recent_git_tag(): try: git_tag = str( subprocess.check_output(['git', 'describe', '--abbrev=0'], stderr=subprocess.STDOUT) ).strip('\'b\\n') except subprocess.CalledProcessError as exc_info: raise Exception(str(exc_info.output)) return git_tag
Example 2
Source File: git_utils.py From dagster with Apache License 2.0 | 6 votes |
def get_git_tag(): try: git_tag = str( subprocess.check_output( ['git', 'describe', '--exact-match', '--abbrev=0'], stderr=subprocess.STDOUT ) ).strip('\'b\\n') except subprocess.CalledProcessError as exc_info: match = re.search( 'fatal: no tag exactly matches \'(?P<commit>[a-z0-9]+)\'', str(exc_info.output) ) if match: raise Exception( 'Bailing: there is no git tag for the current commit, {commit}'.format( commit=match.group('commit') ) ) raise Exception(str(exc_info.output)) return git_tag
Example 3
Source File: build.py From com.visualstudio.code.oss with GNU Affero General Public License v3.0 | 6 votes |
def get_git_with_tag(url, tag): stream = io.TextIOWrapper(urllib.request.urlopen(url + '/info/refs?service=git-upload-pack')) refs = {} while True: line = stream.readline() line = line[4:] if line == '': break if line.startswith('#'): continue line = line.split('\0')[0] line = line.split(' ') refs[line[1].strip()] = line[0] return { 'type': 'git', 'url': url, 'tag': tag, 'commit': refs.get('refs/tags/' + tag + '^{}', refs.get('refs/tags/' + tag)) }
Example 4
Source File: Repository.py From gist-alfred with MIT License | 5 votes |
def get_git_tag(self, sha): """ :calls: `GET /repos/:owner/:repo/git/tags/:sha <http://developer.github.com/v3/git/tags>`_ :param sha: string :rtype: :class:`github.GitTag.GitTag` """ assert isinstance(sha, (str, unicode)), sha headers, data = self._requester.requestJsonAndCheck( "GET", self.url + "/git/tags/" + sha ) return github.GitTag.GitTag(self._requester, headers, data, completed=True)
Example 5
Source File: pkg.py From marvin-python-toolbox with Apache License 2.0 | 5 votes |
def get_git_tag(path=None): if path is None: path = os.path.curdir command = 'git rev-list --tags --max-count=1'.split() commit = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=path).stdout.read().decode('utf-8') command = 'git describe --tags {}'.format(commit).split() tag = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=path).stdout.read().decode('utf-8') return tag.strip()
Example 6
Source File: github.py From flow with Apache License 2.0 | 5 votes |
def get_git_last_tag(self, start_from_version=None): method = "get_git_last_tag" commons.print_msg(GitHub.clazz, method, 'begin') if start_from_version is not None: return start_from_version last_tag = None if self.config.artifact_category.lower() == 'release': tags = self.get_all_tags_and_shas_from_github(need_release=1) for name, _ in tags: if '+' not in name: last_tag = name break else: tags = self.get_all_tags_and_shas_from_github(need_snapshot=1) for name, _ in tags: if '+' in name: last_tag = name break commons.print_msg(GitHub.clazz, method, "last_tag is: {}".format(last_tag)) return last_tag
Example 7
Source File: github.py From flow with Apache License 2.0 | 5 votes |
def get_git_previous_tag(self, start_from_version=None): method = "get_git_previous_tag" commons.print_msg(GitHub.clazz, method, 'begin') beginning_tag = None if self.config.artifact_category.lower() == 'release': tags = self.get_all_tags_and_shas_from_github(need_release=2) else: tags = self.get_all_tags_and_shas_from_github(need_snapshot=2) if start_from_version is None: for name, _ in tags: if self.config.artifact_category.lower() == 'release' and '+' not in name: beginning_tag = name break elif self.config.artifact_category.lower() != 'release' and '+' in name: beginning_tag = name break else: beginning_tag = start_from_version commons.print_msg(GitHub.clazz, method, "starting with {}".format(beginning_tag)) commons.print_msg(GitHub.clazz, method, "Category: " + self.config.artifact_category.lower()) found_tag = False for name, _ in tags: if found_tag: out_name = None if self.config.artifact_category.lower() == 'release' and '+' not in name: out_name = name elif self.config.artifact_category.lower() != 'release' and '+' in name: out_name = name if out_name is not None: commons.print_msg(GitHub.clazz, method, name) commons.print_msg(GitHub.clazz, method, 'end') return out_name if name == beginning_tag: found_tag = True commons.print_msg(GitHub.clazz, method, 'tag not found, or was the first tag') return None
Example 8
Source File: Update.py From AIL-framework with GNU Affero General Public License v3.0 | 5 votes |
def get_git_current_tag(current_version_path): try: with open(current_version_path, 'r') as version_content: version = version_content.read() except FileNotFoundError: version = 'v1.4' with open(current_version_path, 'w') as version_content: version_content.write(version) version = version.replace(" ", "").splitlines()[0] if version[0] != 'v': version = 'v{}'.format(version) return version
Example 9
Source File: info.py From upribox with GNU General Public License v3.0 | 5 votes |
def get_git_tag(self): try: self.tag = subprocess.check_output(['/usr/bin/git', '-C', self.GIT_REPO_LOCAL_DIR, 'describe', '--tags']).strip() except: pass
Example 10
Source File: RepoUtil.py From broc with Apache License 2.0 | 5 votes |
def GetGitTagName(target_dir, logger): """ get git tag name from it's local path Args : path : local path of module logger : the object of Log.Log Returns : return git tag name of module,if enconters some errors return None """ branch_info = _get_git_status_info(target_dir, logger) if branch_info.find('branch') != -1: return None return branch_info.split(' ')[-1]
Example 11
Source File: _version_helper.py From pycbc with GNU General Public License v3.0 | 5 votes |
def get_git_tag(hash_, git_path='git'): """Returns the name of the current git tag """ tag, status = call((git_path, 'describe', '--exact-match', '--tags', hash_), returncode=True) if status == 0: return tag else: return None