Skip to content

Commit

Permalink
Merge pull request #544 from openlawlibrary/release/0.31.0
Browse files Browse the repository at this point in the history
chore: release 0.31.0
  • Loading branch information
renatav authored Oct 1, 2024
2 parents 967ca6a + 9e8f952 commit ebc3e1b
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 144 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning][semver].

### Added

### Changed

### Fixed


## [0.31.0] - 09/28/2024

### Added


- Added lxml to taf pyinstaller to execute arbitrary python scripts ([535])
- Added support for execution of executable files within the scripts directories ([529])
Expand Down Expand Up @@ -1255,7 +1264,8 @@ and this project adheres to [Semantic Versioning][semver].

[keepachangelog]: https://keepachangelog.com/en/1.0.0/
[semver]: https://semver.org/spec/v2.0.0.html
[unreleased]: https://github.com/openlawlibrary/taf/compare/v0.30.2...HEAD
[unreleased]: https://github.com/openlawlibrary/taf/compare/v0.31.0...HEAD
[0.31.0]: https://github.com/openlawlibrary/taf/compare/v0.30.2...0.31.0
[0.30.2]: https://github.com/openlawlibrary/taf/compare/v0.30.1...v0.30.2
[0.30.1]: https://github.com/openlawlibrary/taf/compare/v0.30.0...v0.30.1
[0.30.0]: https://github.com/openlawlibrary/taf/compare/v0.29.1...v0.30.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

PACKAGE_NAME = "taf"
VERSION = "0.30.2"
VERSION = "0.31.0"
AUTHOR = "Open Law Library"
AUTHOR_EMAIL = "[email protected]"
DESCRIPTION = "Implementation of archival authentication"
Expand Down
15 changes: 11 additions & 4 deletions taf/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,14 +839,15 @@ def branch_unpushed_commits(self, branch_name):
local_branch = repo.branches.get(branch_name)
if local_branch is None:
# local branch does not exist
return False
return False, []
try:
upstream_full_name = local_branch.upstream_name
except KeyError:
return True
# no local branch => no unpushed local commit
return False, []
if not upstream_full_name:
# no upstream branch - not pushed
return True
return True, []
parts = upstream_full_name.split("/")
upstream_name = "/".join(parts[2:])

Expand All @@ -865,7 +866,7 @@ def branch_unpushed_commits(self, branch_name):
else:
break

return [commit.id for commit in unpushed_commits]
return bool(unpushed_commits), [commit.id for commit in unpushed_commits]

def commit(self, message: str) -> str:
self._git("add -A")
Expand Down Expand Up @@ -1487,6 +1488,12 @@ def set_remote_url(self, new_url: str, remote: Optional[str] = "origin") -> None
self._git(f"remote set-url {remote} {new_url}")

def set_upstream(self, branch_name: str) -> None:
repo = self.pygit_repo
try:
repo.resolve_refish(f"origin/{branch_name}")
except KeyError:
return

self._git("branch -u origin/{}", branch_name)

def something_to_commit(self) -> bool:
Expand Down
3 changes: 2 additions & 1 deletion taf/resources/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ TAF_CLI="taf"
LAST_VALIDATED_COMMIT=$($TAF_CLI repo latest-commit)
if [ $? -ne 0 ]; then
echo "Failed to retrieve the last validated commit."
exit 1
# Change here to continue instead of exiting
LAST_VALIDATED_COMMIT=""
fi

# Log the commit information before running the validation
Expand Down
8 changes: 6 additions & 2 deletions taf/tests/test_git/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ def test_branch_unpushed_commits(repository, clone_repository):
clone_repository.clone_from_disk(repository.path, keep_remote=True)
branch = clone_repository.branches()[0]
clone_repository.reset_num_of_commits(1, True)
assert not len(clone_repository.branch_unpushed_commits(branch))
has_unpushed, unpushed_commits = clone_repository.branch_unpushed_commits(branch)
assert not has_unpushed
assert not len(unpushed_commits)
(clone_repository.path / "test3.txt").write_text("Updated test3")
clone_repository.commit(message="Update test3.txt")
assert len(clone_repository.branch_unpushed_commits(branch))
has_unpushed, unpushed_commits = clone_repository.branch_unpushed_commits(branch)
assert has_unpushed
assert len(unpushed_commits)


def test_is_git_repository_root_bare(repository):
Expand Down
66 changes: 58 additions & 8 deletions taf/tests/test_updater/test_update/test_update_different_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,13 @@ def test_update_unpushed_commits_auth_repo(origin_auth_repo, client_dir):
setup_manager = SetupManager(client_auth_repo)
setup_manager.add_task(update_expiration_dates, kwargs={"push": False})
setup_manager.execute_tasks()
assert len(
client_auth_repo.branch_unpushed_commits(client_auth_repo.default_branch)

has_unpushed, _ = client_auth_repo.branch_unpushed_commits(
client_auth_repo.default_branch
)

assert has_unpushed

# the update should fail without the force flag
update_invalid_repos_and_check_if_repos_exist(
OperationType.UPDATE,
Expand All @@ -203,9 +206,10 @@ def test_update_unpushed_commits_auth_repo(origin_auth_repo, client_dir):
num_of_commits_to_remove=num_of_commits_to_remove,
)

assert not len(
client_auth_repo.branch_unpushed_commits(client_auth_repo.default_branch)
has_unpushed, _ = client_auth_repo.branch_unpushed_commits(
client_auth_repo.default_branch
)
assert not has_unpushed


@pytest.mark.parametrize(
Expand Down Expand Up @@ -234,9 +238,10 @@ def test_update_unpushed_commits_target_repo(origin_auth_repo, client_dir):
kwargs={"target_name": client_target_repo.name},
)
setup_manager.execute_tasks()
assert len(
client_target_repo.branch_unpushed_commits(client_target_repo.default_branch)
has_unpushed, _ = client_target_repo.branch_unpushed_commits(
client_target_repo.default_branch
)
assert has_unpushed

# the update should fail without the force flag
update_invalid_repos_and_check_if_repos_exist(
Expand All @@ -257,10 +262,12 @@ def test_update_unpushed_commits_target_repo(origin_auth_repo, client_dir):
num_of_commits_to_remove=num_of_commits_to_remove,
)

assert not len(
client_target_repo.branch_unpushed_commits(client_target_repo.default_branch)
has_unpushed, _ = client_target_repo.branch_unpushed_commits(
client_target_repo.default_branch
)

assert not has_unpushed


@pytest.mark.parametrize(
"origin_auth_repo",
Expand Down Expand Up @@ -489,3 +496,46 @@ def test_update_with_last_validated_commit_not_in_local_repo(
client_dir,
force=True,
)


@pytest.mark.parametrize(
"origin_auth_repo",
[
{
"targets_config": [{"name": "target1"}, {"name": "target2"}],
},
],
indirect=True,
)
def test_update_with_targets_repo_having_a_local_branch_not_on_remote_origin_expect_error(
origin_auth_repo, client_dir
):
clone_repositories(origin_auth_repo, client_dir)

setup_manager = SetupManager(origin_auth_repo)
setup_manager.add_task(add_valid_target_commits)
setup_manager.execute_tasks()

origin_top_commit_sha = origin_auth_repo.head_commit_sha()
client_auth_repo = AuthenticationRepository(client_dir, origin_auth_repo.name)
client_auth_repo.set_last_validated_commit(origin_top_commit_sha)
client_target_repo_path = client_auth_repo.path.parent / "target1"
client_target_repo = GitRepository(path=client_target_repo_path)

client_target_repo.checkout_branch("branch-not-synced-with-remote", create=True)
client_target_repo.commit_empty("Add new commit that diverges from default branch")

update_invalid_repos_and_check_if_repos_exist(
OperationType.UPDATE,
origin_auth_repo,
client_dir,
LVC_NOT_IN_REPO_PATTERN,
True,
)

update_and_check_commit_shas(
OperationType.UPDATE,
origin_auth_repo,
client_dir,
force=True,
)
1 change: 0 additions & 1 deletion taf/tools/cli/taf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"metadata": "taf.tools.metadata.attach_to_group",
"roles": "taf.tools.roles.attach_to_group",
"yubikey": "taf.tools.yubikey.attach_to_group",
"scripts": "taf.tools.scripts.attach_to_group",
})
@click.version_option()
def taf():
Expand Down
50 changes: 0 additions & 50 deletions taf/tools/scripts/__init__.py

This file was deleted.

8 changes: 2 additions & 6 deletions taf/updater/lifecycle_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,8 @@ def execute_scripts(auth_repo, last_commit, scripts_rel_path, data, scripts_root
if Path(script_path).suffix == ".py":
if getattr(sys, "frozen", False):
# we are running in a pyinstaller bundle
output = run(
f"{sys.executable}",
"scripts",
"execute",
script_path,
input=json_data,
taf_logger.warning(
"Warning: executing scripts from pyinstaller executable is not supported"
)
else:
output = run(f"{sys.executable}", script_path, input=json_data)
Expand Down
Loading

0 comments on commit ebc3e1b

Please sign in to comment.