Skip to content

Commit

Permalink
Merge pull request #3496 from lasote/feature/clean_git_get_branch
Browse files Browse the repository at this point in the history
Fixed Git class, wrongly replacing characters from the branch name
  • Loading branch information
memsharded authored Sep 6, 2018
2 parents 3cef81c + a54ac09 commit d8e068f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 0 additions & 2 deletions conans/client/tools/scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ def get_branch(self):
status = self.run("status -bs --porcelain")
# ## feature/scm_branch...myorigin/feature/scm_branch
branch = status.splitlines()[0].split("...")[0].strip("#").strip()
# Replace non alphanumeric
branch = re.sub('[^0-9a-zA-Z]+', '_', branch)
return branch
except Exception as e:
raise ConanException("Unable to get git branch from %s\n%s" % (self.folder, str(e)))
5 changes: 4 additions & 1 deletion conans/test/util/tools_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,12 +1217,15 @@ def _create_paths():

def git_to_capture_branch_test(self):
conanfile = """
import re
from conans import ConanFile, tools
def get_version():
git = tools.Git()
try:
return "%s_%s" % (git.get_branch(), git.get_revision())
branch = git.get_branch()
branch = re.sub('[^0-9a-zA-Z]+', '_', branch)
return "%s_%s" % (branch, git.get_revision())
except:
return None
Expand Down

0 comments on commit d8e068f

Please sign in to comment.