Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions hpccm/templates/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@ def clone_step(self, branch=None, commit=None, directory='', path='/tmp',

if commit:
clone.extend(['cd {0}'.format(posixpath.join(path, directory)),
'git checkout {0}'.format(commit),
'cd -'])
'git checkout {0}'.format(commit)])
if recursive:
# `git clone --recursive` initializes submodules for the
# initially cloned revision. Re-sync them after checking out
# a pinned commit, whose gitlinks may differ.
clone.append('git submodule update --init --recursive')
clone.append('cd -')

# Add labels if the caller inherits from the labels template
if callable(getattr(self, 'add_annotation', None)):
Expand Down
8 changes: 8 additions & 0 deletions test/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ def test_commit(self):
verify='fatal'),
'mkdir -p /tmp && cd /tmp && git clone https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd - && cd /tmp/hpc-container-maker && git checkout ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c && cd -')

def test_commit_recursive(self):
"""git with specified commit and recursive submodules"""
g = git()
self.assertEqual(g.clone_step(repository='https://github.com/NVIDIA/hpc-container-maker.git',
commit='ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c',
recursive=True),
'mkdir -p /tmp && cd /tmp && git clone --recursive https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd - && cd /tmp/hpc-container-maker && git checkout ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c && git submodule update --init --recursive && cd -')

def test_branch_and_commit(self):
"""git with both specified branch and specified commit"""
g = git()
Expand Down
Loading