Class BranchFilteredIntegrationStrategy

  • All Implemented Interfaces:
    IGitIntegrationStrategy

    public class BranchFilteredIntegrationStrategy
    extends Object
    Implementation of IGitIntegrationStrategy based on branch filtering.

    A branch filter defines a set of branches for a project, for which snapshots are enabled. The strategy permits a snapshot task if all conditions apply:

    • Snapshots are enabled for the respective branch, i.e. creation for the source branch or restoration for the target branch.
    • (For creation) A snapshot for source branch does not exist.
    • (For restoration) A snapshot for target branch exists.
    • The task is meaningful, e.g. source and target branches have different heads.
    • Repository is in a safe state.
    • There are no uncommitted or untracked changes in working tree.
    • Constructor Detail

      • BranchFilteredIntegrationStrategy

        public BranchFilteredIntegrationStrategy​(IBranchFilter branchFilter,
                                                 ISnapshotUserApprovalCallback userApprovalCallback)
        Constructs a new strategy with the given branch filter and user approval callback.
        Parameters:
        branchFilter - the branch filter, cannot be null
        userApprovalCallback - the user approval callback, cannot be null
    • Method Detail

      • shallKeepSnapshot

        public boolean shallKeepSnapshot​(org.eclipse.core.resources.IProject project,
                                         org.eclipse.jgit.lib.Repository repo,
                                         org.eclipse.jgit.lib.ObjectId revision)
        Description copied from interface: IGitIntegrationStrategy
        Tests whether a snapshot may be required in future. The snapshot is referred to by a project and commit.

        This method is used for garbage collection purposes and does not affect snapshot creation or restoration.

        Parameters:
        project - the project, never null
        repo - the repository, associated with the project, never null
        revision - SHA-1 of the commit, never null
        Returns:
        true if the snapshot shall be kept, false otherwise
      • requestUserApproval

        public boolean requestUserApproval​(SnapshotGitRequest[] requests)
        Description copied from interface: IGitIntegrationStrategy
        Requests user approval of a snapshot operation consisting of the given requests.
        Specified by:
        requestUserApproval in interface IGitIntegrationStrategy
        Parameters:
        requests - the requests, never null
        Returns:
        true if a user approved the operation, false otherwise