MCPcopy Create free account
hub / github.com/RubinCarter/gitflow4idea-plus / GitflowImpl

Class GitflowImpl

src/main/java/gitflow/GitflowImpl.java:20–506  ·  view source on GitHub ↗

@author Opher Vishnia / opherv.com / opherv@gmail.com

Source from the content-addressed store, hash-verified

18 */
19
20public class GitflowImpl extends GitImpl implements Gitflow {
21
22 //we must use reflection to add this command, since the git4idea implementation doesn't expose it
23 private GitCommand GitflowCommand() {
24 Method m = null;
25 try {
26 m = GitCommand.class.getDeclaredMethod("write", String.class);
27 } catch (NoSuchMethodException e) {
28 e.printStackTrace();
29 }
30 //m.invoke(d);//exception java.lang.IllegalAccessException
31 m.setAccessible(true);//Abracadabra
32
33 GitCommand command = null;
34
35 try {
36 command = (GitCommand) m.invoke(null, "flow");//now its ok
37 } catch (IllegalAccessException e) {
38 e.printStackTrace();
39 } catch (InvocationTargetException e) {
40 e.printStackTrace();
41 }
42
43 return command;
44 }
45
46
47 private void addOptionsCommand(GitLineHandler h, Project project, String optionId){
48 HashMap<String,String> optionMap = GitflowOptionsFactory.getOptionById(optionId);
49 if (GitflowConfigurable.isOptionActive(project, optionMap.get("id"))){
50 h.addParameters(optionMap.get("flag"));
51 }
52 }
53
54 public GitCommandResult initRepo(@NotNull GitRepository repository,
55 GitflowInitOptions initOptions, @Nullable GitLineHandlerListener... listeners) {
56 return callInit(repository, initOptions, false, listeners);
57 }
58
59 public GitCommandResult reInitRepo(@NotNull GitRepository repository,
60 GitflowInitOptions initOptions,
61 @Nullable GitLineHandlerListener... listeners) {
62 return callInit(repository, initOptions, true, listeners);
63 }
64
65 private GitCommandResult callInit(@NotNull GitRepository repository,
66 GitflowInitOptions initOptions, boolean reInit,
67 @Nullable GitLineHandlerListener[] listeners) {
68 GitLineHandler h;
69 if (initOptions.isUseDefaults()) {
70 h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand());
71 } else {
72 h = new GitInitLineHandler(initOptions, repository.getProject(),
73 repository.getRoot(), GitflowCommand());
74 }
75
76 h.setSilent(false);
77 h.setStdoutSuppressed(false);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected