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

don't change directory in download_repo function in tools.github #3486

Merged
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
3 changes: 1 addition & 2 deletions easybuild/tools/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from easybuild.framework.easyconfig.parser import EasyConfigParser
from easybuild.tools.build_log import EasyBuildError, print_msg, print_warning
from easybuild.tools.config import build_option
from easybuild.tools.filetools import apply_patch, change_dir, copy_dir, copy_easyblocks, copy_framework_files
from easybuild.tools.filetools import apply_patch, copy_dir, copy_easyblocks, copy_framework_files
from easybuild.tools.filetools import det_patched_files, download_file, extract_file
from easybuild.tools.filetools import get_easyblock_class_name, mkdir, read_file, symlink, which, write_file
from easybuild.tools.py2vs3 import HTTPError, URLError, ascii_letters, urlopen
Expand Down Expand Up @@ -364,7 +364,6 @@ def download_repo(repo=GITHUB_EASYCONFIGS_REPO, branch='master', account=GITHUB_
_log.debug("%s downloaded to %s, extracting now" % (base_name, path))

base_dir = extract_file(target_path, path, forced=True, change_into_dir=False)
change_dir(base_dir)
extracted_path = os.path.join(base_dir, extracted_dir_name)

# check if extracted_path exists
Expand Down
5 changes: 5 additions & 0 deletions test/framework/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ def test_download_repo(self):
print("Skipping test_download_repo, no GitHub token available?")
return

cwd = os.getcwd()

# default: download tarball for master branch of easybuilders/easybuild-easyconfigs repo
path = gh.download_repo(path=self.test_prefix, github_user=GITHUB_TEST_ACCOUNT)
repodir = os.path.join(self.test_prefix, 'easybuilders', 'easybuild-easyconfigs-master')
Expand All @@ -354,6 +356,9 @@ def test_download_repo(self):
self.assertTrue(re.match('^[0-9a-f]{40}$', read_file(shafile)))
self.assertTrue(os.path.exists(os.path.join(repodir, 'easybuild', 'easyconfigs', 'f', 'foss', 'foss-2019b.eb')))

# current directory should not have changed after calling download_repo
self.assertTrue(os.path.samefile(cwd, os.getcwd()))

# existing downloaded repo is not reperformed, except if SHA is different
account, repo, branch = 'boegel', 'easybuild-easyblocks', 'develop'
repodir = os.path.join(self.test_prefix, account, '%s-%s' % (repo, branch))
Expand Down