Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for .git-file.#89

New issue

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

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 2 commits intogitpython-developers:0.3frommarcusrbrown:feature/0.3/git-file-support
Nov 19, 2014
Merged
Show file tree
Hide file tree
Changes fromall commits
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
12 changes: 12 additions & 0 deletionsgit/repo/base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -71,6 +71,7 @@ class Repo(object):
re_hexsha_shortened = re.compile('^[0-9A-Fa-f]{4,40}$')
re_author_committer_start = re.compile(r'^(author|committer)')
re_tab_full_line = re.compile(r'^\t(.*)$')
re_git_file_gitdir = re.compile('gitdir: (.*)')

# invariants
# represents the configuration level of a configuration file
Expand DownExpand Up@@ -113,6 +114,17 @@ def __init__(self, path=None, odbt = DefaultDBType):
self.git_dir = gitpath
self._working_tree_dir = curpath
break
if isfile(gitpath):
line = open(gitpath, 'r').readline().strip()
match = self.re_git_file_gitdir.match(line)
if match:
gitpath = match.group(1)
if not os.path.isabs(gitpath):
gitpath = os.path.normpath(join(curpath, gitpath))
if is_git_dir(gitpath):
self.git_dir = gitpath
self._working_tree_dir = curpath
break
curpath, dummy = os.path.split(curpath)
if not dummy:
break
Expand Down
1 change: 1 addition & 0 deletionsgit/test/fixtures/git_file
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
gitdir: ./.real
17 changes: 17 additions & 0 deletionsgit/test/test_repo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -594,6 +594,23 @@ def test_repo_odbtype(self):
target_type = GitCmdObjectDB
assert isinstance(self.rorepo.odb, target_type)

@with_rw_repo('HEAD')
def test_git_file(self, rwrepo):
# Move the .git directory to another location and create the .git file.
real_path_abs = os.path.abspath(join_path_native(rwrepo.working_tree_dir, '.real'))
os.rename(rwrepo.git_dir, real_path_abs)
git_file_path = join_path_native(rwrepo.working_tree_dir, '.git')
open(git_file_path, 'wb').write(fixture('git_file'))

# Create a repo and make sure it's pointing to the relocated .git directory.
git_file_repo = Repo(rwrepo.working_tree_dir)
assert os.path.abspath(git_file_repo.git_dir) == real_path_abs

# Test using an absolute gitdir path in the .git file.
open(git_file_path, 'wb').write('gitdir: %s\n' % real_path_abs)
git_file_repo = Repo(rwrepo.working_tree_dir)
assert os.path.abspath(git_file_repo.git_dir) == real_path_abs

def test_submodules(self):
assert len(self.rorepo.submodules) == 1# non-recursive
assert len(list(self.rorepo.iter_submodules())) >= 2
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp