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_branch(self): """Test git_current_branch() function""" self.assertEqual(git_current_branch(self.kit_project_path), 'master')