1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.scm.provider.git.jgit;
20
21 import javax.annotation.Priority;
22 import javax.inject.Inject;
23 import javax.inject.Named;
24 import javax.inject.Singleton;
25
26 import java.util.function.Consumer;
27
28 import org.apache.maven.scm.provider.ScmProvider;
29 import org.apache.maven.scm.provider.git.command.GitCommand;
30 import org.apache.maven.scm.provider.git.jgit.command.checkin.JGitCheckInCommand;
31 import org.apache.maven.scm.provider.git.jgit.command.checkout.JGitCheckOutCommand;
32 import org.apache.maven.scm.provider.git.jgit.command.remoteinfo.JGitRemoteInfoCommand;
33 import org.codehaus.plexus.components.interactivity.Prompter;
34 import org.eclipse.jgit.api.TransportCommand;
35
36
37
38
39 @Singleton
40 @Named("jgit")
41 @Priority(1)
42 public class JGitTestScmProvider extends JGitScmProvider implements ScmProvider {
43 private Consumer<JGitCheckInCommand> checkInCommandCallback;
44 private Consumer<JGitCheckOutCommand> checkOutCommandCallback;
45 private Consumer<JGitRemoteInfoCommand> remoteInfoCommandCallback;
46
47 @Inject
48 public JGitTestScmProvider(Prompter prompter) {
49 super(prompter);
50 }
51
52 public void registerCheckInCommandCallback(Consumer<JGitCheckInCommand> gitCommandConsumer) {
53 checkInCommandCallback = gitCommandConsumer;
54 }
55
56 public void registerCheckOutCommandCallback(Consumer<JGitCheckOutCommand> gitCommandConsumer) {
57 checkOutCommandCallback = gitCommandConsumer;
58 }
59
60 public void registerRemoteInfoCommandCallback(Consumer<JGitRemoteInfoCommand> gitCommandConsumer) {
61 remoteInfoCommandCallback = gitCommandConsumer;
62 }
63
64 @Override
65 protected GitCommand getCheckInCommand() {
66 JGitCheckInCommand command = (JGitCheckInCommand) super.getCheckInCommand();
67 if (checkInCommandCallback != null) {
68 checkInCommandCallback.accept(command);
69 }
70 return command;
71 }
72
73 @Override
74 protected GitCommand getCheckOutCommand() {
75 JGitCheckOutCommand command = (JGitCheckOutCommand) super.getCheckOutCommand();
76 if (checkOutCommandCallback != null) {
77 checkOutCommandCallback.accept(command);
78 }
79 return command;
80 }
81
82 @Override
83 protected GitCommand getRemoteInfoCommand() {
84 JGitRemoteInfoCommand command = (JGitRemoteInfoCommand) super.getRemoteInfoCommand();
85 if (remoteInfoCommandCallback != null) {
86 remoteInfoCommandCallback.accept(command);
87 }
88 return command;
89 }
90 }