Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

upstream tldr mindlessly changed master to main #49

Open
nopdotcom opened this issue May 28, 2021 · 3 comments
Open

upstream tldr mindlessly changed master to main #49

nopdotcom opened this issue May 28, 2021 · 3 comments

Comments

@nopdotcom
Copy link

tldr.py/tldr/cli.py

Lines 139 to 145 in 4f8065a

local = subprocess.check_output('git rev-parse master'.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 master'.split())
is now broken.

Update your code to participate in the performance.

@lord63
Copy link
Owner

lord63 commented Jul 17, 2021

Tested in my local environment, still works. tldr-pages repo still has master branch and it is even with main. But I agree that we should switch to use the main branch in the future.
See #50

@nopdotcom
Copy link
Author

Yeah, apparently official notice was at https://github.com/tldr-pages/tldr/releases/tag/v1.5b .

They seem pretty adamant that you should be using tldr.zip as a cache, using the term MUST. See https://github.com/tldr-pages/tldr/blob/main/CLIENT-SPECIFICATION.md#caching and note that questions about "what branch are we on" aren't important if you're doing that. The spec was updated here

On the other hand, a .zip file may be the silliest way to distribute tldr. I downloaded their zip file, and recompressed it:

$ ls -lS tldr*
-rw-r--r-- 1 nop wheel 2110917 Jul 18 06:48 tldr.zip
-rw-r--r-- 1 nop wheel  947712 Jul 18 13:07 tldr.tar.gz
-rw-r--r-- 1 nop wheel  888664 Jul 18 13:04 tldr.tar.zst
-rw-r--r-- 1 nop wheel  684995 Jul 18 13:32 tldr.tar.zst18
-rw-r--r-- 1 nop wheel  672568 Jul 18 13:04 tldr.tar.xz

The only thing I can figure out is that they expect you to simply store the zip file, and use zipfile.ZipFile.namelist() and ZipFile.open() as your caching strategy.

(The perfect thing would be generating tldr.tar.xz using https://github.com/vasi/pixz, as just about everybody can read LZMA and tar files these days. Unfortunately, pixz's magic isn't available outside the utility. A Python binding would be cool.)

Should I open a bug on the alleged "MUST" issue to document it, or is this enough?

@threepistons
Copy link

I cooked up the following workaround for 0.7.0. This adds an optional config key called repo_branch, in case your in-house tldr repo uses a different branch name, and sets the branch to "main" if you don't set the key. Works on my rig.

root@mybox:/usr/lib/python3/dist-packages/tldr# diff config.py-DIST config.py
36a37,38
>     if not 'repo_branch' in config.keys():
>         config['repo_branch'] = 'main'
root@mybox:/usr/lib/python3/dist-packages/tldr# diff cli.py-DIST cli.py
110a111
>     repo_branch = get_config()['repo_branch']
114c115,116
<     local = subprocess.check_output('git rev-parse master'.split()).strip()
---
>     local_cmd = 'git rev-parse ' + repo_branch
>     local = subprocess.check_output(local_cmd.split()).strip()
120c122,123
<         subprocess.check_call('git checkout master'.split())
---
>         checkout_cmd = 'git checkout ' + repo_branch
>         subprocess.check_call(checkout_cmd.split())

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants