Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #34 from laurentb/fix-repo-discovery

Let git find out where the repo is
  • Loading branch information...
commit 9e64b1dad60954ae58610d9049061ff226b695dd 2 parents 5202e48 + 3416d24
@kennethreitz authored
Showing with 6 additions and 20 deletions.
  1. +0 −15 legit/helpers.py
  2. +6 −5 legit/scm.py
View
15 legit/helpers.py
@@ -16,18 +16,3 @@
is_osx = (_platform == 'darwin')
is_win = (_platform == 'windows')
is_lin = (_platform == 'linux')
-
-
-def find_path_above(*names):
- """Attempt to locate given path by searching parent dirs."""
-
- path = '.'
-
- while os.path.split(os.path.abspath(path))[1]:
- for name in names:
- joined = os.path.join(path, name)
- if os.path.exists(joined):
- return os.path.abspath(joined)
- path = os.path.join('..', path)
-
-
View
11 legit/scm.py
@@ -9,13 +9,13 @@
import os
import sys
+import subprocess
from collections import namedtuple
from operator import attrgetter
from git import Repo, Git
from git.exc import GitCommandError
-from .helpers import find_path_above
from .settings import settings
@@ -208,11 +208,12 @@ def publish_branch(branch):
def get_repo():
"""Returns the current Repo, based on path."""
- bare_path = find_path_above('.git')
+ work_path = subprocess.Popen([git, 'rev-parse', '--show-toplevel'],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE).communicate()[0].rstrip('\n')
- if bare_path:
- prelapsarian_path = os.path.split(bare_path)[0]
- return Repo(prelapsarian_path)
+ if work_path:
+ return Repo(work_path)
else:
return None
Please sign in to comment.
Something went wrong with that request. Please try again.