Get the most recent commit of the source branch.
12005
function (cb) {
      async.map(self._repos, function (repo, repoCb) {
        self._client.gitdata.getReference({
          user: self._repoParts[repo].org,
          repo: self._repoParts[repo].repo,
          ref: branchSrcFull
        }, function (err, res) {
          if (self._checkAndHandleError(err, repo, repoCb)) { return; }
          repoCb(null, {
            repo: repo,
            sha: res.object.sha
          });
        });
      }, cb);
    }
795533
def r_update(self):
        

        # Getting Master Branch
        upstream = self.get_ref(self.master_upstream, origin=self.upstream)
        if isinstance(upstream, bool):
            return (ProxyError(
                404, "Upstream Master branch '{0}' does not exist".format(self.master_upstream),
                step="get_upstream_ref"
            )).response()
        elif isinstance(upstream, self.ProxyError):
            return upstream.response()

        # Patching
        new_sha = self.patch_ref(upstream)
        if isinstance(new_sha, self.ProxyError):
            return new_sha.response()

        self.logger.info("Updated repository {} to sha {}".format(self.origin, new_sha), extra={"former_sha": upstream})
        return jsonify({
            "status": "success",
            "commit": new_sha
        })
141987
def fetch_changes(repo_path, up_commit='master'):
    
    last_up_commit = None
    prevcwd = os.getcwd()
    try:
        gitexe = 'git'
        os.chdir(repo_path)
        old_sources_timestamp = sources_latest_timestamp('.')
        shell_command([gitexe, 'pull'])
        last_up_commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'])
        shell_command([gitexe, 'checkout', up_commit])
        up_commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'])
        new_sources_timestamp = sources_latest_timestamp('.')
        if old_sources_timestamp < new_sources_timestamp:
            with open('.timestamp', 'w') as up_commit_file:
                up_commit_file.write(up_commit)
    finally:
        os.chdir(prevcwd)
    return last_up_commit, up_commit
1185348
def get_tree_from_branch(self, ref):
        '''
        
        '''
        try:
            return git.RemoteReference(
                self.repo,
                'refs/remotes/origin/{0}'.format(ref)).commit.tree
        except ValueError:
            return None
667467
def git_branch(self):
        """"""
        info = self.info
        return 'rpm-{major}.{minor}.x'.format(
            major=info[0], minor=info[1])
584457
def get_git_version(path):
    """"""
    branch_name = get_git_cleaned_branch_name(path)
    # Determine whether working copy is dirty (i.e. contains modified files)
    mods = run_cmd(path, 'git', 'status', '--porcelain', '--untracked-files=no')
    dirty = '.dirty' if mods else ''
    # Get a list of all commits on branch, with corresponding branch/tag refs
    # Each line looks something like: "d3e4d42 (HEAD, master, tag: v0.1)"
    git_output = run_cmd(path, 'git', 'log', '--pretty="%h%d"')
    commits = git_output.strip().replace('"', '').split('\n')
    num_commits_since_branch = len(commits)
    # Short hash of the latest commit
    short_commit_name = commits[0].partition(' ')[0]
    # A valid version is sequence of dotted numbers optionally prefixed by 'v'
    valid_version = re.compile(r'^v?([\.\d]+)$')

    def tagged_version(commit):
        """First tag on commit that is valid version, as a list of numbers."""
        refs = commit.partition(' ')[2]
        for ref in refs.lstrip('(').rstrip(')').split(', '):
            if ref.startswith('tag: '):
                tag = ref[5:].lower()
                found = valid_version.match(tag)
                if found:
                    return [int(v) for v in found.group(1).split('.') if v]
        return []
    # Walk back along branch and find first valid tagged version (or use 0.0)
    for commit in commits:
        version_numbers = tagged_version(commit)
        if version_numbers:
            break
    else:
        version_numbers = [0, 0]
    # It is a release if current commit has a version tag (and dir is clean)
    release = (commit == commits[0]) and not dirty
    if not release:
        # We are working towards the next (minor) release according to PEP 440
        version_numbers[-1] += 1
    version = '.'.join([str(v) for v in version_numbers])
    if not release:
        # Development version contains extra embellishments
        version = ("%s.dev%d+%s.%s%s" % (version, num_commits_since_branch,
                                         branch_name, short_commit_name, dirty))
    return version
293393
def get_lastblock(cls, impl, working_dir):
        
        if not cls.db_exists(impl, working_dir):
            return None

        con = cls.db_open(impl, working_dir)
        query = 'SELECT MAX(block_id) FROM snapshots;'
        
        rows = cls.db_query_execute(con, query, (), verbose=False)
        ret = None
        for r in rows:
            ret = r['MAX(block_id)']

        con.close()
        return ret
63211
function getCommits(repo, branchName) {
  return caller.call(repo, repo.commits, branchName)
  .then(function (commits) {
    return commits.map(function (commitObj) {
      return {
        id: commitObj.id,
        message: commitObj.message,
        committed_date: commitObj.committed_date
      }
    })
  })
}
469127
def last_commit():
    """"""
    try:
        root = subprocess.check_output(
            ['hg', 'parent', '--template={node}'],
            stderr=subprocess.STDOUT).strip()
        # Convert to unicode first
        return root.decode('utf-8')
    except subprocess.CalledProcessError:
        return None
1351917
def get_list_commits(self, branch: str = None,
                         reverse_order: bool = True) \
            -> Generator[Commit, None, None]:
        
        for commit in self.repo.iter_commits(branch, reverse=reverse_order):
            yield self.get_commit_from_gitpython(commit)
921632
def find_upstream_changed(self, kind):
        
        output = subprocess.check_output([
            'git', 'log', '{}..origin/{}'.format(self.branch_name, self.branch_name),
            '--oneline', '--name-status'
        ], cwd=self.repo_dir).decode()
        files = []
        for line in output.split('\n'):
            if line.startswith(kind):
                files.append(os.path.join(self.repo_dir, line.split('\t', 1)[1]))

        return files
329016
def last_commit(self) -> Tuple:
        """"""
        from libs.repos import git

        return git.get_last_commit(repo_path=self.path)
1038233
def commit_status(base_commit, new_commit, ignore: [])
      base_tree = get_object(base_commit.tree) unless base_commit.nil?
      new_tree  = get_object(new_commit.tree)  unless new_commit.nil?

      Utils::Status.compare_trees base_tree,
                                  new_tree,
                                  object_store,
                                  ignore: ignore
    end
518533
def has_commit(self):
        
        current_revision = self.history.current_revision
        revision_id = self.state.revision_id

        return current_revision.revision_id != revision_id
190525
def get_head(self) -> Commit:
        
        head_commit = self.repo.head.commit
        return Commit(head_commit, self.path, self.main_branch)
61188
def get_last_commit_modifying_files(repo: Repo, *files) -> str:
    
    return repo.git.log(*files, n=1, format="%H")
641605
def current_branch(self):
        """"""
        branch_name = git(self.gitdir, self.gitwd, "symbolic-ref", "HEAD")
        return branch_name.replace('refs/heads/', '').strip()