Skip to content

Instantly share code, notes, and snippets.

@rubenwardy

rubenwardy/so.md Secret

Created June 7, 2018 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubenwardy/88167015a8d46d33858e70522869e6a6 to your computer and use it in GitHub Desktop.
Save rubenwardy/88167015a8d46d33858e70522869e6a6 to your computer and use it in GitHub Desktop.

Problem

I'm using gitpython on celery to clone public repositories and manipulate them. If a user specifies a private repository, it blocks the program whilst waiting for input from the screen where celery runs.

 -------------- celery@rubenPC v4.0.2 (latentcall)
---- **** ----- 
--- * ***  * --
-- * - **** --- 
- ** ---------- [config]
- ** ---------- .> app:         app:0x7f31d3e7afd0
- ** ---------- .> transport:   redis://localhost:6379//
- ** ---------- .> results:     redis://localhost:6379/
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** ----- 
 -------------- [queues]
                .> celery           exchange=celery(direct) key=celery

Repo URL: http://example.com/user/privaterepo
Username for 'https://gitlab.com': 

This causes the worker to be unusable, and never exit the job. kill_after_timeout doesn't make a difference.

Here is my code:

print("Repo URL: " + urlstr)
repo = git.Repo.clone_from(urlstr, gitDir, \
		progress=None, env=None, depth=1, recursive=True, kill_after_timeout=15)

git://

I've tried hanging to git://. This causes the client to be stuck on Cloning into dir forever - I can reproduce this just using git clone git://URL. kill_after_timeout doesn't make a difference.

crendential.helper

The following command works on pure CLI:

git clone -c credential.helper='!f() { cat > /dev/null; echo username=; echo password=; }; f' http://example.com/user/privaterepo

However I can't work out how to specify the above using GitPython.

print("Repo URL: " + urlstr)
repo = git.Repo.clone_from(urlstr, gitDir, \
        c="credential.helper='!f() { cat > /dev/null; echo username=; echo password=; }; f'", \
		progress=None, env=None, depth=1, recursive=True, kill_after_timeout=15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment