Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Implemented Linux support
  • Loading branch information
dviol committed Nov 5, 2018
commit 8f9434768a788798e64ac0f223d8efb70085d82f
12 changes: 6 additions & 6 deletions git-repository-downloader/git-downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def check_and_create_dir(path):

def download_file(base_url, local_dir, relative_path):
remote_path = base_url + "/" + relative_path
local_path = local_dir + "\\" + relative_path.replace("/", "\\")
local_path = os.path.join(local_dir, relative_path)

print "downloading the file from %s to %s" % (remote_path, local_path)

r = requests.get(remote_path, stream=True)
if r.status_code == 200:
check_and_create_dir(local_path[0: local_path.rfind("\\")])
check_and_create_dir(local_path[0: local_path.rfind("/")])
with open(local_path, "wb+") as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
Expand Down Expand Up @@ -54,7 +54,7 @@ def find_sha1(message):
working_dir = url
working_dir = working_dir.replace("http://", "")
working_dir = working_dir.replace("http://", "")
working_dir = os.getcwd() + "\\" + working_dir
working_dir = os.path.join(os.getcwd(), working_dir)

print "Set the working directory: %s" % working_dir

Expand Down Expand Up @@ -100,10 +100,10 @@ def find_sha1(message):

# Download missing objects
for SHA1 in SHA1s:
git_path = ".git\\objects\\" + SHA1[0:2] + "\\" + SHA1[2:40]
path = working_dir + "\\" + git_path
git_path = os.path.join(".git","objects", SHA1[0:2], SHA1[2:40])
path = os.path.join(working_dir, git_path)
if not os.path.isfile(path):
download_file(url, working_dir, git_path.replace("\\", "/"))
download_file(url, working_dir, git_path)

print "Downloading complete"

Expand Down