This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new 361990519 [Improve] GitUtils code optimization (#3183)
361990519 is described below
commit 361990519f0e8fb5db98a5a90aea450794df9870
Author: ChengJie1053 <[email protected]>
AuthorDate: Mon Sep 25 12:43:30 2023 +0800
[Improve] GitUtils code optimization (#3183)
* optimized code
* Formatted code
---
.../main/java/org/apache/streampark/console/base/util/GitUtils.java | 6 +++++-
.../java/org/apache/streampark/console/core/entity/Project.java | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java
index 7aab84af6..a54117b71 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/GitUtils.java
@@ -22,6 +22,7 @@ import org.apache.streampark.common.util.SystemPropertyUtils;
import org.apache.streampark.console.core.entity.Project;
import org.apache.streampark.console.core.enums.GitCredentialEnum;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import com.jcraft.jsch.JSch;
@@ -54,7 +55,7 @@ public class GitUtils {
CloneCommand cloneCommand =
Git.cloneRepository().setURI(project.getUrl()).setDirectory(project.getAppSource());
- if (project.getBranches() != null) {
+ if (StringUtils.isNotBlank(project.getBranches())) {
cloneCommand.setBranch(Constants.R_HEADS + project.getBranches());
cloneCommand.setBranchesToClone(
Collections.singletonList(Constants.R_HEADS +
project.getBranches()));
@@ -68,6 +69,9 @@ public class GitUtils {
setCredentials(command, project);
Collection<Ref> refList = command.call();
List<String> branchList = new ArrayList<>(4);
+ if (CollectionUtils.isEmpty(refList)) {
+ return branchList;
+ }
for (Ref ref : refList) {
String refName = ref.getName();
if (refName.startsWith(Constants.R_HEADS)) {
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
index fabdfdcb3..453872e80 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
@@ -118,7 +118,7 @@ public class Project implements Serializable {
if (sourcePath.isFile()) {
throw new IllegalArgumentException("[StreamPark] sourcePath must be
directory");
}
- String branches = this.getBranches() == null ? "main" : this.getBranches();
+ String branches = StringUtils.isBlank(this.getBranches()) ? "main" :
this.getBranches();
String rootName = url.replaceAll(".*/|\\.git|\\.svn", "");
String fullName = rootName.concat("-").concat(branches);
String path = String.format("%s/%s/%s", sourcePath.getAbsolutePath(),
getName(), fullName);