diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-12-23 14:32:52 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-12-23 14:38:06 +0800 |
commit | 016c5aee944227e07f244839d3d518a3b33a82c8 (patch) | |
tree | 77d5314303f4d15b1200aaa3bb647aa8ddacf40d | |
parent | 2632ba86dd920267455ee10154b9e2ce4695a889 (diff) |
bugfix: get git branch failed when only 'git fetch' is provided
File "/usr/local/lib/python2.7/dist-packages/functest/cli/commands/cli_env.py", line 58, in show
branch = repo.head.reference
File "/usr/local/lib/python2.7/dist-packages/git/refs/symbolic.py", line 258, in _get_reference
raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha))
TypeError: HEAD is a detached symbolic reference as it points to '2632ba86dd920267455ee10154b9e2ce4695a889'
JIRA: FUNCTEST-673
Change-Id: I2306dde254710d7d0e8a3529a19e3d8fdb6e5b02
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
-rw-r--r-- | functest/cli/commands/cli_env.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/functest/cli/commands/cli_env.py b/functest/cli/commands/cli_env.py index 5228c3e80..9423631bf 100644 --- a/functest/cli/commands/cli_env.py +++ b/functest/cli/commands/cli_env.py @@ -48,10 +48,14 @@ class CliEnv: installer_info = ("%s, %s" % (install_type, installer_ip)) scenario = _get_value(CONST.DEPLOY_SCENARIO) node = _get_value(CONST.NODE_NAME) - repo = git.Repo(CONST.dir_repo_functest) - branch = repo.head.reference - git_branch = branch.name - git_hash = branch.commit.hexsha + repo_h = git.Repo(CONST.dir_repo_functest).head + if repo_h.is_detached: + git_branch = 'detached from FETCH_HEAD' + git_hash = repo_h.commit.hexsha + else: + branch = repo_h.reference + git_branch = branch.name + git_hash = branch.commit.hexsha is_debug = _get_value(CONST.CI_DEBUG, 'false') build_tag = CONST.BUILD_TAG if build_tag is not None: |