Browse Source

Fix indexer breaking http:// URLs.

tags/v1.0^2
Ben Kurtovic 10 years ago
parent
commit
10e7491a40
1 changed files with 5 additions and 6 deletions
  1. +5
    -6
      bitshift/crawler/indexer.py

+ 5
- 6
bitshift/crawler/indexer.py View File

@@ -196,21 +196,20 @@ class GitIndexer(threading.Thread):


.. warning:: .. warning::
Various Git subprocesses will occasionally fail, and, seeing as the Various Git subprocesses will occasionally fail, and, seeing as the
information they provide is a crucial component of some repository file
urls, None may be returned.
information they provide is a crucial component of some repository
file urls, None may be returned.
""" """


try: try:
if framework_name == "GitHub": if framework_name == "GitHub":
default_branch = subprocess.check_output("git branch" default_branch = subprocess.check_output("git branch"
" --no-color", shell=True)[2:-1] " --no-color", shell=True)[2:-1]
return ("%s/blob/%s/%s" % (repo_url, default_branch,
filename)).replace("//", "/")
parts = [repo_url, "blob", default_branch, filename]
elif framework_name == "Bitbucket": elif framework_name == "Bitbucket":
commit_hash = subprocess.check_output("git rev-parse HEAD", commit_hash = subprocess.check_output("git rev-parse HEAD",
shell=True).replace("\n", "") shell=True).replace("\n", "")
return ("%s/src/%s/%s" % (repo_url, commit_hash,
filename)).replace("//", "/")
parts = [repo_url, "src", commit_hash, filename]
return "/".join(s.strip("/") for s in parts)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
return None return None




Loading…
Cancel
Save