Skip to content

Commit

Permalink
Add get_current_branch method in class Git
Browse files Browse the repository at this point in the history
  • Loading branch information
grimmer0125 committed Sep 16, 2021
1 parent afaa690 commit 169bf3c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions poetry/core/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,25 @@ def checkout(self, rev: str, folder: Optional[Path] = None) -> str:

return self.run(*args)

def get_current_branch(self, folder=None):
args = []

if folder is None and self._work_dir:
folder = self._work_dir

if folder:
print("folder is not empty string 2")
args += [
"--git-dir",
(folder / ".git").as_posix(),
"--work-tree",
folder.as_posix(),
]

args += ["rev-parse", "--abbrev-ref", "HEAD"]

return self.run(*args)

def rev_parse(self, rev: str, folder: Optional[Path] = None) -> str:
args = []
if folder is None and self._work_dir:
Expand Down

0 comments on commit 169bf3c

Please sign in to comment.