mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-11 19:04:02 -07:00
Add support for bare git reference repos
This adds two parameters to the git module: bare (boolean) Indicates this is to be a bare repositori reference (string) Indicates the path or url to the reference repo. Check out the "--reference" option in the "git clone" man page Added appropriate tests.
This commit is contained in:
parent
a7121d00ac
commit
f41d4ac390
2 changed files with 101 additions and 34 deletions
|
@ -170,10 +170,13 @@ class TestRunner(unittest.TestCase):
|
|||
def test_git(self):
|
||||
self._run('file', ['path=/tmp/gitdemo', 'state=absent'])
|
||||
self._run('file', ['path=/tmp/gd', 'state=absent'])
|
||||
self._run('file', ['path=/tmp/gdbare', 'state=absent'])
|
||||
self._run('file', ['path=/tmp/gdreference', 'state=absent'])
|
||||
self._run('file', ['path=/tmp/gdreftest', 'state=absent'])
|
||||
self._run('command', ['git init gitdemo', 'chdir=/tmp'])
|
||||
self._run('command', ['touch a', 'chdir=/tmp/gitdemo'])
|
||||
self._run('command', ['git add *', 'chdir=/tmp/gitdemo'])
|
||||
self._run('command', ['git commit -m "test commit 2"', 'chdir=/tmp/gitdemo'])
|
||||
self._run('command', ['git commit -m "test commit 1"', 'chdir=/tmp/gitdemo'])
|
||||
self._run('command', ['touch b', 'chdir=/tmp/gitdemo'])
|
||||
self._run('command', ['git add *', 'chdir=/tmp/gitdemo'])
|
||||
self._run('command', ['git commit -m "test commit 2"', 'chdir=/tmp/gitdemo'])
|
||||
|
@ -186,6 +189,28 @@ class TestRunner(unittest.TestCase):
|
|||
# test the force option when set
|
||||
result = self._run('git', ["repo=\"file:///tmp/gitdemo\"", "dest=/tmp/gd", "force=yes"])
|
||||
assert result['changed']
|
||||
# test the bare option
|
||||
result = self._run('git', ["repo=\"file:///tmp/gitdemo\"", "dest=/tmp/gdbare", "bare=yes", "remote=test"])
|
||||
assert result['changed']
|
||||
# test a no-op fetch
|
||||
result = self._run('git', ["repo=\"file:///tmp/gitdemo\"", "dest=/tmp/gdbare", "bare=yes"])
|
||||
assert not result['changed']
|
||||
# test whether fetch is working for bare repos
|
||||
self._run('command', ['touch c', 'chdir=/tmp/gitdemo'])
|
||||
self._run('command', ['git add *', 'chdir=/tmp/gitdemo'])
|
||||
self._run('command', ['git commit -m "test commit 3"', 'chdir=/tmp/gitdemo'])
|
||||
result = self._run('git', ["repo=\"file:///tmp/gitdemo\"", "dest=/tmp/gdbare", "bare=yes"])
|
||||
assert result['changed']
|
||||
# test reference repos
|
||||
result = self._run('git', ["repo=\"file:///tmp/gdbare\"", "dest=/tmp/gdreference", "bare=yes"])
|
||||
assert result['changed']
|
||||
result = self._run('git', ["repo=\"file:///tmp/gitdemo\"", "dest=/tmp/gdreftest", "reference=/tmp/gdreference/"])
|
||||
assert result['changed']
|
||||
assert os.path.isfile('/tmp/gdreftest/a')
|
||||
result = self._run('command', ['ls', 'chdir=/tmp/gdreference/objects/pack'])
|
||||
assert result['stdout'] != ''
|
||||
result = self._run('command', ['ls', 'chdir=/tmp/gdreftest/.git/objects/pack'])
|
||||
assert result['stdout'] == ''
|
||||
|
||||
def test_file(self):
|
||||
filedemo = tempfile.mkstemp()[1]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue