Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable trace output for commands run in get_source_tarball_from_git #4310

Merged
merged 2 commits into from
Aug 7, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions easybuild/tools/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2646,7 +2646,7 @@ def get_source_tarball_from_git(filename, targetdir, git_config):

tmpdir = tempfile.mkdtemp()
cwd = change_dir(tmpdir)
run.run_cmd(' '.join(clone_cmd), log_all=True, simple=True, regexp=False)
run.run_cmd(' '.join(clone_cmd), log_all=True, simple=True, regexp=False, trace=False)

# If the clone is done into a specified name, change repo_name
if clone_into:
Expand All @@ -2658,14 +2658,14 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
if recursive:
checkout_cmd.extend(['&&', 'git', 'submodule', 'update', '--init', '--recursive'])

run.run_cmd(' '.join(checkout_cmd), log_all=True, simple=True, regexp=False, path=repo_name)
run.run_cmd(' '.join(checkout_cmd), log_all=True, simple=True, regexp=False, path=repo_name, trace=False)

elif not build_option('extended_dry_run'):
# If we wanted to get a tag make sure we actually got a tag and not a branch with the same name
# This doesn't make sense in dry-run mode as we don't have anything to check
cmd = 'git describe --exact-match --tags HEAD'
# Note: Disable logging to also disable the error handling in run_cmd
(out, ec) = run.run_cmd(cmd, log_ok=False, log_all=False, regexp=False, path=repo_name)
(out, ec) = run.run_cmd(cmd, log_ok=False, log_all=False, regexp=False, path=repo_name, trace=False)
if ec != 0 or tag not in out.splitlines():
print_warning('Tag %s was not downloaded in the first try due to %s/%s containing a branch'
' with the same name. You might want to alert the maintainers of %s about that issue.',
Expand All @@ -2684,14 +2684,14 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
if recursive:
cmds.append('git submodule update --init --recursive')
for cmd in cmds:
run.run_cmd(cmd, log_all=True, simple=True, regexp=False, path=repo_name)
run.run_cmd(cmd, log_all=True, simple=True, regexp=False, path=repo_name, trace=False)

# create an archive and delete the git repo directory
if keep_git_dir:
tar_cmd = ['tar', 'cfvz', targetpath, repo_name]
else:
tar_cmd = ['tar', 'cfvz', targetpath, '--exclude', '.git', repo_name]
run.run_cmd(' '.join(tar_cmd), log_all=True, simple=True, regexp=False)
run.run_cmd(' '.join(tar_cmd), log_all=True, simple=True, regexp=False, trace=False)

# cleanup (repo_name dir does not exist in dry run mode)
change_dir(cwd)
Expand Down
32 changes: 17 additions & 15 deletions test/framework/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2742,7 +2742,7 @@ def test_diff_files(self):
self.assertTrue(regex.search(res), "Pattern '%s' found in: %s" % (regex.pattern, res))

@requires_github_access()
def test_get_source_tarball_from_git(self):
def test_github_get_source_tarball_from_git(self):
"""Test get_source_tarball_from_git function."""

target_dir = os.path.join(self.test_prefix, 'target')
Expand Down Expand Up @@ -2775,37 +2775,37 @@ def run_check():
git_repo = {'git_repo': 'git@github.com:easybuilders/testrepository.git'} # Just to make the below shorter
expected = '\n'.join([
r' running command "git clone --depth 1 --branch tag_for_tests %(git_repo)s"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
r' running command "tar cfvz .*/target/test.tar.gz --exclude .git testrepository"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
]) % git_repo
run_check()

git_config['clone_into'] = 'test123'
expected = '\n'.join([
r' running command "git clone --depth 1 --branch tag_for_tests %(git_repo)s test123"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
r' running command "tar cfvz .*/target/test.tar.gz --exclude .git test123"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
]) % git_repo
run_check()
del git_config['clone_into']

git_config['recursive'] = True
expected = '\n'.join([
r' running command "git clone --depth 1 --branch tag_for_tests --recursive %(git_repo)s"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
r' running command "tar cfvz .*/target/test.tar.gz --exclude .git testrepository"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
]) % git_repo
run_check()

git_config['keep_git_dir'] = True
expected = '\n'.join([
r' running command "git clone --branch tag_for_tests --recursive %(git_repo)s"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
r' running command "tar cfvz .*/target/test.tar.gz testrepository"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
]) % git_repo
run_check()
del git_config['keep_git_dir']
Expand All @@ -2814,22 +2814,22 @@ def run_check():
git_config['commit'] = '8456f86'
expected = '\n'.join([
r' running command "git clone --no-checkout %(git_repo)s"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
r' running command "git checkout 8456f86 && git submodule update --init --recursive"',
r" \(in testrepository\)",
r' running command "tar cfvz .*/target/test.tar.gz --exclude .git testrepository"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
]) % git_repo
run_check()

del git_config['recursive']
expected = '\n'.join([
r' running command "git clone --no-checkout %(git_repo)s"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
r' running command "git checkout 8456f86"',
r" \(in testrepository\)",
r' running command "tar cfvz .*/target/test.tar.gz --exclude .git testrepository"',
r" \(in .*/tmp.*\)",
r" \(in /.*\)",
]) % git_repo
run_check()

Expand All @@ -2851,7 +2851,8 @@ def run_check():
self.assertEqual(os.listdir(target_dir), ['test.tar.gz'])
# Check that we indeed downloaded the right tag
extracted_dir = tempfile.mkdtemp(prefix='extracted_dir')
extracted_repo_dir = ft.extract_file(test_file, extracted_dir, change_into_dir=False)
with self.mocked_stdout_stderr():
extracted_repo_dir = ft.extract_file(test_file, extracted_dir, change_into_dir=False)
self.assertTrue(os.path.isfile(os.path.join(extracted_repo_dir, 'this-is-a-branch.txt')))
os.remove(test_file)

Expand All @@ -2865,7 +2866,8 @@ def run_check():
self.assertTrue(os.path.isfile(test_file))
# Check that we indeed downloaded the tag and not the branch
extracted_dir = tempfile.mkdtemp(prefix='extracted_dir')
extracted_repo_dir = ft.extract_file(test_file, extracted_dir, change_into_dir=False)
with self.mocked_stdout_stderr():
extracted_repo_dir = ft.extract_file(test_file, extracted_dir, change_into_dir=False)
self.assertTrue(os.path.isfile(os.path.join(extracted_repo_dir, 'this-is-a-tag.txt')))

del git_config['tag']
Expand Down