示例#1
0
 def get_yaml(self):
     """Return python object representation for saving yaml"""
     return {'name': self.name,
             'path': self.path,
             'ref': git_current_sha(self.full_path()),
             'remote': self.remote_name,
             'source': self.source.name}
示例#2
0
 def get_yaml(self):
     """Return python object representation for saving yaml"""
     forks_yaml = [f.get_yaml() for f in self.forks]
     return {'name': self.name,
             'path': self.path,
             'depth': self.depth,
             'forks': forks_yaml,
             'ref': git_current_sha(self.full_path()),
             'remote': self.remote_name,
             'source': self.source.name}
示例#3
0
def format_ref_string(repo_path):
    """Return formatted repo ref name"""
    local_commits = git_new_local_commits(repo_path)
    upstream_commits = git_new_upstream_commits(repo_path)
    no_local_commits = local_commits == 0 or local_commits == '0'
    no_upstream_commits = upstream_commits == 0 or upstream_commits == '0'
    if no_local_commits and no_upstream_commits:
        status = ''
    else:
        local_commits_output = colored('+' + str(local_commits), 'yellow')
        upstream_commits_output = colored('-' + str(upstream_commits), 'red')
        status = ' (' + local_commits_output + '/' + upstream_commits_output + ')'

    if git_is_detached(repo_path):
        current_ref = git_current_sha(repo_path)
        return colored('(HEAD @ ' + current_ref + ')', 'magenta')
    else:
        current_branch = git_current_branch(repo_path)
        return colored('(' + current_branch + ')', 'magenta') + status
 def test_git_current_sha(self):
     """Test git_current_sha() function"""
     self.assertEqual(git_current_sha(self.sasha_project_path), self.sha_ref)