openlawlibrary / taf

The Archive Framework
GNU Affero General Public License v3.0
10 stars 10 forks source link

Revert to last valid state if invalid commits found #484

Closed renatav closed 3 months ago

renatav commented 4 months ago

Currently, if target repositories are out of sync with the authentication repositories, we start the validation from the beginning, and not the last validated commit. If the validation fails, repositories will be updated up to the last valid commit. That should automatically remove all invalid commits from the local repositories.

Create the following tests (some might already exist, we should check):

  1. Client's authentication repository and target repositories are not in sync. Authentication repository contains some commits following the last validated commit. Target repositories are in sync with the last validated commit - simulate the case when someone used git pull to update the authentication repository. In fact, that is probably how we want to set this up. Run the updater to clone all repositories (an auth repo and its targets, we should not make this more complicated by testing the update of a repo with dependencies). Make valid changes to both the auth repo and the target repos (only origin repos). Sync client's auth repo with remote without running the updater. Run the updater. Expect and check that all repositories were successfully updated to the last remote commit
    1. Client's authentication repository is on last validated commits, but target repositories contain commits following the last validated ones. Simulate the case when someone used git pull to update the one or more target repositories. Run the updater to clone all repositories. Make valid changes to both the auth repo and the target repos (only origin repos). Sync one or more target repos with remote without running the updater. Run the updater. Expect and check that all repositories were successfully updated to the last remote commit.
    2. Clients auth repo has been manually updated, just like in 1. The update should result in a partial update. Clients auth repo should be reverted to the last valid commit, last validated commits set to that value, target repositories updated up to commits listed in auth repo's last validated commits
    3. Same as 2, but target repositories contain invalid commits following commits which were manually pulled using git pull. Expect all repositories to be updated up to the last validated commits and invalid commits to be removed
    4. Client's auth repo is not on last validated commit, but target commits are all over the place. Some are after last validated, some are before. At the moment, i believe that the validation will start from the beginning in such a case and will be successful if there are no invalid commits.

There is some room to improve the performance here: