Class BranchFilteredIntegrationStrategy
- java.lang.Object
-
- com.e1c.g5.v8.dt.snapshot.integration.git.BranchFilteredIntegrationStrategy
-
- All Implemented Interfaces:
IGitIntegrationStrategy
public class BranchFilteredIntegrationStrategy extends Object
Implementation ofIGitIntegrationStrategy
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 Summary
Constructors Constructor Description BranchFilteredIntegrationStrategy(IBranchFilter branchFilter, ISnapshotUserApprovalCallback userApprovalCallback)
Constructs a new strategy with the given branch filter and user approval callback.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
requestUserApproval(SnapshotGitRequest[] requests)
Requests user approval of a snapshot operation consisting of the given requests.boolean
shallKeepSnapshot(org.eclipse.core.resources.IProject project, org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.lib.ObjectId revision)
Tests whether a snapshot may be required in future.boolean
wantCreateSnapshot(IGitBoundProjectStateDelta delta, ISnapshotLocationProvider locationProvider)
Tests whether it is desired to create a snapshot on the given Git-associated project state transition.boolean
wantRestoreSnapshot(IGitBoundProjectStateDelta delta, ISnapshotLocationProvider locationProvider)
Tests whether it is desired to restore a snapshot on the given Git-associated project state transition.
-
-
-
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 benull
userApprovalCallback
- the user approval callback, cannot benull
-
-
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, nevernull
repo
- the repository, associated with the project, nevernull
revision
- SHA-1 of the commit, nevernull
- Returns:
true
if the snapshot shall be kept,false
otherwise
-
wantCreateSnapshot
public boolean wantCreateSnapshot(IGitBoundProjectStateDelta delta, ISnapshotLocationProvider locationProvider)
Description copied from interface:IGitIntegrationStrategy
Tests whether it is desired to create a snapshot on the given Git-associated project state transition.- Specified by:
wantCreateSnapshot
in interfaceIGitIntegrationStrategy
- Parameters:
delta
- the Git-associated project state delta, nevernull
locationProvider
- , the snapshot location provider, nevernull
- Returns:
true
if the snapshot creation is desired
-
wantRestoreSnapshot
public boolean wantRestoreSnapshot(IGitBoundProjectStateDelta delta, ISnapshotLocationProvider locationProvider)
Description copied from interface:IGitIntegrationStrategy
Tests whether it is desired to restore a snapshot on the given Git-associated project state transition.- Specified by:
wantRestoreSnapshot
in interfaceIGitIntegrationStrategy
- Parameters:
delta
- the Git-associated project state delta, nevernull
locationProvider
- , the snapshot location provider, nevernull
- Returns:
true
if the snapshot restoration is desired
-
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 interfaceIGitIntegrationStrategy
- Parameters:
requests
- the requests, nevernull
- Returns:
true
if a user approved the operation,false
otherwise
-
-