Skip to content

Commit

Permalink
Merge branch 'master' into tsadra-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kaldan007 committed Mar 18, 2021
2 parents 044e119 + f4550b3 commit 15d0577
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

<!--next-version-placeholder-->

## v0.7.13 (2021-03-17)
### Fix
* Cbranch checkout in pecha download ([`d89c607`](https://github.com/OpenPecha/openpecha-toolkit/commit/d89c607f5d78d92975833b1ec9bb92cefe99da7b))

## v0.7.12 (2021-03-16)
### Fix
* Assets path ([`6a602b6`](https://github.com/OpenPecha/openpecha-toolkit/commit/6a602b62e647002aab780bb3142a5085b895b6f6))
Expand Down
2 changes: 1 addition & 1 deletion openpecha/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Version of openpecha-toolkit package
__version__ = "0.7.12"
__version__ = "0.7.13"
19 changes: 5 additions & 14 deletions openpecha/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ def _get_batch(batch_path):
return pecha_list


def get_branch(repo, branch):
if branch in repo.heads:
return branch
return "master"


def download_pecha(pecha_id, out_path=None, needs_update=True, branch="main"):
# clone the repo
pecha_url = f"{config['OP_ORG']}/{pecha_id}.git"
Expand All @@ -118,19 +112,16 @@ def download_pecha(pecha_id, out_path=None, needs_update=True, branch="main"):
pecha_path = config["OP_PECHAS_PATH"] / pecha_id

if pecha_path.is_dir(): # if repo is already exits at local then try to pull
if not needs_update:
return pecha_path
repo = Repo(str(pecha_path))
branch_to_pull = get_branch(repo, branch)
repo.heads[branch_to_pull].checkout()
click.echo(INFO.format(f"Updating {pecha_id} ..."))
repo.git.pull("origin", branch_to_pull)
repo.git.checkout(branch)
if needs_update:
click.echo(INFO.format(f"Updating {pecha_id} ..."))
repo.git.pull("origin", branch)
else:
click.echo(INFO.format(f"Downloading {pecha_id} ..."))
Repo.clone_from(pecha_url, str(pecha_path))
repo = Repo(str(pecha_path))
branch_to_pull = get_branch(repo, branch)
repo.git.checkout(branch_to_pull)
repo.git.checkout(branch)
return pecha_path


Expand Down

0 comments on commit 15d0577

Please sign in to comment.