Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def it_creates_missing_directories(config):
shell.rm(config.location)
expect(gitman.install('gitman_1', depth=1)) == True
expect(os.listdir(config.location)) == ['gitman_1']
def it_should_fail_on_dirty_repositories(config):
expect(gitman.update(depth=1, lock=False)) == True
shell.rm(os.path.join("deps", "gitman_1", ".project"))
try:
with pytest.raises(UncommittedChanges):
gitman.lock()
expect(config.datafile.text).does_not_contain("")
finally:
shell.rm(os.path.join("deps", "gitman_1"))
):
"""Ensure the source matches the specified revision."""
log.info("Updating source files...")
# Clone the repository if needed
if not os.path.exists(self.name):
git.clone(
self.type,
self.repo,
self.name,
sparse_paths=self.sparse_paths,
rev=self.rev,
)
# Enter the working tree
shell.cd(self.name)
if not git.valid():
if force:
git.rebuild(self.type, self.repo)
fetch = True
else:
raise self._invalid_repository
# Check for uncommitted changes
if not force:
log.debug("Confirming there are no uncommitted changes...")
if skip_changes:
if git.changes(
self.type, include_untracked=clean, display_status=False
):
common.show(
f'Skipped update due to uncommitted changes in {os.getcwd()}',
def run_scripts(self, force=False):
log.info("Running install scripts...")
# Enter the working tree
shell.cd(self.name)
if not git.valid():
raise self._invalid_repository
# Check for scripts
if not self.scripts:
common.show("(no scripts to run)", color='shell_info')
common.newline()
return
# Run all scripts
for script in self.scripts:
try:
lines = shell.call(script, _shell=True)
except exceptions.ShellError as exc:
common.show(*exc.output, color='shell_error')
cmd = exc.program
def identify(self, allow_dirty=True, allow_missing=True, skip_changes=False):
"""Get the path and current repository URL and hash."""
if os.path.isdir(self.name):
shell.cd(self.name)
if not git.valid():
raise self._invalid_repository
path = os.getcwd()
url = git.get_url(self.type)
if git.changes(
self.type,
display_status=not allow_dirty and not skip_changes,
_show=not skip_changes,
):
if allow_dirty:
common.show(self.DIRTY, color='git_dirty', log=False)
common.newline()
return path, url, self.DIRTY
def get_top_level_dependencies(self):
"""Yield the path, repository, and hash of top-level dependencies."""
if not os.path.exists(self.location_path):
return
shell.cd(self.location_path)
common.newline()
common.indent()
for source in self.sources:
yield os.path.join(self.location_path, source.name)
shell.cd(self.location_path, _show=False)
common.dedent()