Open jackblk opened 3 years ago
Merging #50 (6d7c630) into master (877f923) will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## master #50 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 183 183
=========================================
Hits 183 183
Impacted Files | Coverage Δ | |
---|---|---|
tldr/cli.py | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 4f8065a...6d7c630. Read the comment docs.
Is it compatible if someone download the repo before master renamed to main? Because main branch may not exist and you can't checkout to it.
How about this:
main_branch = "master"
if subprocess.call('git rev-parse --verify main'.split()) == 0: # check if main branch exist
main_branch = "main"
local = subprocess.check_output('git rev-parse {0}'.format(main_branch).split()).strip()
remote = subprocess.check_output(
'git ls-remote https://github.com/tldr-pages/tldr/ HEAD'.split()
).split()[0]
if local != remote:
click.echo("Updating...")
subprocess.check_call('git checkout {0}'.format(main_branch).split())
Is it compatible if someone download the repo before master renamed to main? Because main branch may not exist and you can't checkout to it.
I missed this case, thanks for mentioning it.
About git rev-parse --verify main
, the argument --verify
does not seem to verify if the branch is there or not.
--verify Verify that exactly one parameter is provided, and that it can be turned into a raw 20-byte SHA-1 that can be used to access the object database. If so, emit it to the standard output; otherwise, error out.
Also, in your example, if main
does not exist then it will still use master
, but this branch will be deleted in the future.
How about this?
def update():
"""Update to the latest pages."""
repo_directory = get_config()["repo_directory"]
os.chdir(repo_directory)
click.echo("Check for updates...")
try:
local = subprocess.check_output("git rev-parse main".split()).strip()
except subprocess.CalledProcessError:
subprocess.check_call("git fetch -p".split())
subprocess.check_call("git checkout main".split())
local = subprocess.check_output("git rev-parse main".split()).strip()
remote = subprocess.check_output(
"git ls-remote https://github.com/tldr-pages/tldr/ HEAD".split()
).split()[0]
if local != remote:
click.echo("Updating...")
subprocess.check_call("git checkout main".split())
subprocess.check_call("git pull --rebase".split())
build_index()
click.echo("Update to the latest and rebuild the index.")
else:
click.echo("No need for updates.")
Hi, any updates on this PR?
To fit this release: https://github.com/tldr-pages/tldr/releases/tag/v1.5b