1919import com .flow .platform .api .domain .job .JobCategory ;
2020import com .flow .platform .api .envs .GitEnvs ;
2121import com .flow .platform .core .exception .IllegalParameterException ;
22+ import com .flow .platform .util .git .JGitUtil ;
2223import com .flow .platform .util .git .model .GitCommit ;
2324import com .flow .platform .util .git .model .GitEvent ;
2425import com .flow .platform .util .git .model .GitEventType ;
@@ -67,13 +68,13 @@ public static Map<String, String> convert(GitEvent event) {
6768
6869 // the branch is on source for open pr
6970 if (pr .getState () == State .OPEN ) {
70- info .put (GitEnvs .FLOW_GIT_BRANCH .name (), simpleRef (pr .getSource ().getBranch ()));
71+ info .put (GitEnvs .FLOW_GIT_BRANCH .name (), JGitUtil . simpleRef (pr .getSource ().getBranch ()));
7172 info .put (GitEnvs .FLOW_GIT_AUTHOR .name (), pr .getSubmitter ());
7273 }
7374
7475 // the branch is on target for close pr
7576 if (pr .getState () == State .CLOSE ) {
76- info .put (GitEnvs .FLOW_GIT_BRANCH .name (), simpleRef (pr .getTarget ().getBranch ()));
77+ info .put (GitEnvs .FLOW_GIT_BRANCH .name (), JGitUtil . simpleRef (pr .getTarget ().getBranch ()));
7778 info .put (GitEnvs .FLOW_GIT_AUTHOR .name (), pr .getMergedBy ());
7879 }
7980
@@ -93,7 +94,7 @@ public static Map<String, String> convert(GitEvent event) {
9394 Map <String , String > info = new HashMap <>(10 );
9495 info .put (GitEnvs .FLOW_GIT_EVENT_TYPE .name (), pt .getType ().name ());
9596 info .put (GitEnvs .FLOW_GIT_EVENT_SOURCE .name (), pt .getGitSource ().name ());
96- info .put (GitEnvs .FLOW_GIT_BRANCH .name (), simpleRef (pt .getRef ()));
97+ info .put (GitEnvs .FLOW_GIT_BRANCH .name (), JGitUtil . simpleRef (pt .getRef ()));
9798 info .put (GitEnvs .FLOW_GIT_AUTHOR .name (), pt .getUsername ());
9899 info .put (GitEnvs .FLOW_GIT_AUTHOR_EMAIL .name (), pt .getUserEmail ());
99100 info .put (GitEnvs .FLOW_GIT_COMMIT_ID .name (), pt .getAfter ());
@@ -113,15 +114,4 @@ public static Map<String, String> convert(GitEvent event) {
113114
114115 throw new IllegalParameterException ("Git event type not supported" );
115116 }
116-
117- /**
118- * Simplify ref from 'ref/head/master' to 'master'
119- */
120- private static String simpleRef (String ref ) {
121- int slashIndex = ref .lastIndexOf ('/' );
122- if (slashIndex == -1 ) {
123- return ref ;
124- }
125- return ref .substring (slashIndex + 1 );
126- }
127117}
0 commit comments