@@ -43,8 +43,8 @@ associated documentation files (the "Software"), to deal in the Software without
4343import java .net .URLDecoder ;
4444import java .nio .charset .Charset ;
4545import java .util .Arrays ;
46- import java .util .List ;
4746import java .util .Map ;
47+ import java .util .StringJoiner ;
4848import java .util .concurrent .atomic .AtomicBoolean ;
4949import java .util .concurrent .atomic .AtomicReference ;
5050import java .util .logging .Logger ;
@@ -177,15 +177,10 @@ public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException
177177 SecurityContext saveCtx = ACL .impersonate (ACL .SYSTEM );
178178
179179 try {
180- String ref = (String ) jsonObject .get ("ref" );
181- String [] components = ref .split ("/" );
182- if (components .length > 3 ) {
183- /* refs contains branch/tag with a slash */
184- List <String > test = Arrays .asList (ref .split ("/" ));
185- ref = String .join ("%2F" , test .subList (2 , test .size ()));
186- } else {
187- ref = components [components .length - 1 ];
188- }
180+ StringJoiner stringJoiner = new StringJoiner ("%2F" );
181+ Pattern .compile ("/" ).splitAsStream ((String ) jsonObject .get ("ref" )).skip (2 )
182+ .forEach (stringJoiner ::add );
183+ String ref = stringJoiner .toString ();
189184
190185 Arrays .asList (jobName , jobName + "/" + ref ).forEach (j -> {
191186 Job job = GogsUtils .find (j , Job .class );
@@ -223,7 +218,7 @@ public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException
223218 } else if (isNullOrEmpty (jSecret .get ()) && isNullOrEmpty (gSecret )) {
224219 /* No password is set in Jenkins and Gogs, run without secrets */
225220 result = payloadProcessor .triggerJobs (jobName , gogsDelivery );
226- } else if (!isNullOrEmpty (jSecret .get ()) && jSecret .equals (gSecret )) {
221+ } else if (!isNullOrEmpty (jSecret .get ()) && jSecret .get (). equals (gSecret )) {
227222 /* Password is set in Jenkins and Gogs, and is correct */
228223 result = payloadProcessor .triggerJobs (jobName , gogsDelivery );
229224 } else {
0 commit comments