@@ -109,35 +109,34 @@ def _clone_repo(self, base_dir_path, repo_dir_name, verbosity):
109
109
def _current_ref (self ):
110
110
"""Determine the *name* associated with HEAD.
111
111
112
- If we're on a branch, then returns the branch name; otherwise,
113
- if we're on a tag, then returns the tag name; otherwise, returns
112
+ If we're on a tag, then returns the tag name; otherwise, returns
114
113
the current hash. Returns an empty string if no reference can be
115
114
determined (e.g., if we're not actually in a git repository).
115
+
116
+ If we're on a branch, then the branch name is also included in
117
+ the returned string (in addition to the tag / hash).
116
118
"""
117
119
ref_found = False
118
120
119
- # If we're on a branch, then use that as the current ref
120
- branch_found , branch_name = self ._git_current_branch ()
121
- if branch_found :
122
- current_ref = branch_name
121
+ # If we're exactly at a tag, use that as the current ref
122
+ tag_found , tag_name = self ._git_current_tag ()
123
+ if tag_found :
124
+ current_ref = tag_name
123
125
ref_found = True
124
126
125
- if not ref_found :
126
- # Otherwise, if we're exactly at a tag, use that as the
127
- # current ref
128
- tag_found , tag_name = self ._git_current_tag ()
129
- if tag_found :
130
- current_ref = tag_name
131
- ref_found = True
132
-
133
127
if not ref_found :
134
128
# Otherwise, use current hash as the current ref
135
129
hash_found , hash_name = self ._git_current_hash ()
136
130
if hash_found :
137
131
current_ref = hash_name
138
132
ref_found = True
139
133
140
- if not ref_found :
134
+ if ref_found :
135
+ # If we're on a branch, include branch name in current ref
136
+ branch_found , branch_name = self ._git_current_branch ()
137
+ if branch_found :
138
+ current_ref = "{} ({})" .format (branch_name , current_ref )
139
+ else :
141
140
# If we still can't find a ref, return empty string. This
142
141
# can happen if we're not actually in a git repo
143
142
current_ref = ''
0 commit comments