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

command-update #36

Merged
merged 2 commits into from
Aug 3, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/rail/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ def clone_source(outdir, git_mode, dry_run, package_file, **kwargs):
"""Install packages from source"""
scripts.clone_source(outdir, git_mode, dry_run, package_file)
return 0


@cli.command()
@options.outdir(default='..')
@options.dry_run()
@options.package_file()
def update_source(outdir, dry_run, package_file, **kwargs):
"""Update packages from source"""
scripts.update_source(outdir, dry_run, package_file)
return 0



@cli.command()
@options.outdir(default='..')
@options.dry_run()
Expand Down
21 changes: 21 additions & 0 deletions src/rail/cli/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,27 @@
else:
os.system(com_line)


def update_source(outdir, dry_run, package_file):

with open(package_file) as pfile:
package_dict = yaml.safe_load(pfile)

currentpath = os.path.abspath('.')
for key, val in package_dict.items():
abspath = os.path.abspath(f"{outdir}/{key}")

if os.path.exists(f"{outdir}/{key}") is not True:
print(f"Package {outdir}/{key} does not exist!")
continue

com_line = f"cd {abspath} && git pull && cd {currentpath}"

Check warning on line 88 in src/rail/cli/scripts.py

View check run for this annotation

Codecov / codecov/patch

src/rail/cli/scripts.py#L88

Added line #L88 was not covered by tests

if dry_run:
print(com_line)

Check warning on line 91 in src/rail/cli/scripts.py

View check run for this annotation

Codecov / codecov/patch

src/rail/cli/scripts.py#L90-L91

Added lines #L90 - L91 were not covered by tests
else:
os.system(com_line)

Check warning on line 93 in src/rail/cli/scripts.py

View check run for this annotation

Codecov / codecov/patch

src/rail/cli/scripts.py#L93

Added line #L93 was not covered by tests


def install(outdir, from_source, dry_run, package_file):

Expand Down
4 changes: 4 additions & 0 deletions tests/cli/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def test_clone_source():
scripts.clone_source('..', GitMode.https, True, 'rail_packages.yml')
scripts.clone_source('..', GitMode.cli, True, 'rail_packages.yml')


def test_update_source():
scripts.update_source('..', True, 'rail_packages.yml')


def test_install():
scripts.install('..', False, True, 'rail_packages.yml')
Expand Down
Loading