diff options
author | Tommi Virtanen <tv@eagain.net> | 2007-12-31 19:30:27 +0200 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2008-01-22 00:54:28 -0800 |
commit | 4751015af643e69a76207ea705cbfa46d82efab9 (patch) | |
tree | 6cd8c3f1b7d9c8f99d0adeac66976d3c60c9f6b1 | |
parent | Don't always init repository when doing fast-import. (diff) | |
download | gitosis-dakkar-4751015af643e69a76207ea705cbfa46d82efab9.tar.gz gitosis-dakkar-4751015af643e69a76207ea705cbfa46d82efab9.tar.bz2 gitosis-dakkar-4751015af643e69a76207ea705cbfa46d82efab9.zip |
Allow using fast_import for more than initial commit.
-rw-r--r-- | gitosis/repository.py | 16 | ||||
-rw-r--r-- | gitosis/test/test_repository.py | 28 |
2 files changed, 40 insertions, 4 deletions
diff --git a/gitosis/repository.py b/gitosis/repository.py index 304e491..272c3cb 100644 --- a/gitosis/repository.py +++ b/gitosis/repository.py @@ -70,6 +70,7 @@ def fast_import( commit_msg, committer, files, + parent=None, ): """ Create an initial commit. @@ -104,10 +105,17 @@ committer %(committer)s now data %(commit_msg_len)d %(commit_msg)s """ % dict( - committer=committer, - commit_msg_len=len(commit_msg), - commit_msg=commit_msg, - )) + committer=committer, + commit_msg_len=len(commit_msg), + commit_msg=commit_msg, + )) + if parent is not None: + assert not parent.startswith(':') + child.stdin.write("""\ +from %(parent)s +""" % dict( + parent=parent, + )) for index, (path, content) in enumerate(files): child.stdin.write('M 100644 :%d %s\n' % (index+1, path)) child.stdin.close() diff --git a/gitosis/test/test_repository.py b/gitosis/test/test_repository.py index 5f49074..6bc9e76 100644 --- a/gitosis/test/test_repository.py +++ b/gitosis/test/test_repository.py @@ -320,3 +320,31 @@ exec git "$@" got = readFile(os.path.join(tmp, 'cookie')) eq(got, magic_cookie) +def test_fast_import_parent(): + tmp = maketemp() + path = os.path.join(tmp, 'repo.git') + repository.init(path=path) + repository.fast_import( + git_dir=path, + commit_msg='foo initial bar', + committer='Mr. Unit Test <unit.test@example.com>', + files=[ + ('foo', 'bar\n'), + ], + ) + repository.fast_import( + git_dir=path, + commit_msg='another', + committer='Sam One Else <sam@example.com>', + parent='refs/heads/master^0', + files=[ + ('quux', 'thud\n'), + ], + ) + export = os.path.join(tmp, 'export') + repository.export( + git_dir=path, + path=export, + ) + eq(sorted(os.listdir(export)), + sorted(['foo', 'quux'])) |