Unverified Commit fffe53ef authored by ZackYoung's avatar ZackYoung Committed by GitHub

[Fix]fix git bug (#3429)

parent d30910ff
...@@ -151,6 +151,12 @@ ...@@ -151,6 +151,12 @@
<dependency> <dependency>
<groupId>org.dromara.sms4j</groupId> <groupId>org.dromara.sms4j</groupId>
<artifactId>sms4j-spring-boot-starter</artifactId> <artifactId>sms4j-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>cn.hutool</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
......
...@@ -32,6 +32,7 @@ import java.util.function.Consumer; ...@@ -32,6 +32,7 @@ import java.util.function.Consumer;
import org.eclipse.jgit.api.CloneCommand; import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.LsRemoteCommand; import org.eclipse.jgit.api.LsRemoteCommand;
import org.eclipse.jgit.api.PullCommand;
import org.eclipse.jgit.api.TransportCommand; import org.eclipse.jgit.api.TransportCommand;
import org.eclipse.jgit.api.TransportConfigCallback; import org.eclipse.jgit.api.TransportConfigCallback;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
...@@ -95,7 +96,6 @@ public class GitRepository { ...@@ -95,7 +96,6 @@ public class GitRepository {
FileUtil.mkdir(targetFile); FileUtil.mkdir(targetFile);
File writeFile = new File(targetFile, branch); File writeFile = new File(targetFile, branch);
Git git;
try { try {
CloneCommand cloneCommand = CloneCommand cloneCommand =
...@@ -109,9 +109,8 @@ public class GitRepository { ...@@ -109,9 +109,8 @@ public class GitRepository {
.readEnvironment() .readEnvironment()
.findGitDir() .findGitDir()
.build(); .build();
git = new Git(repository); try (Git git = new Git(repository)) {
git.pull() PullCommand pullCommand = git.pull().setProgressMonitor(new TextProgressMonitor(new StringWriter() {
.setProgressMonitor(new TextProgressMonitor(new StringWriter() {
@Override @Override
public void write(String str) { public void write(String str) {
if (logFile != null) { if (logFile != null) {
...@@ -120,19 +119,23 @@ public class GitRepository { ...@@ -120,19 +119,23 @@ public class GitRepository {
if (consumer != null) { if (consumer != null) {
consumer.accept(str); consumer.accept(str);
} }
System.out.println(str); log.info(str);
super.write(str); super.write(str);
} }
})) }));
.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password)) if (!StrUtil.hasBlank(username, password)) {
.call(); pullCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password));
git.close(); }
pullCommand.call();
}
} else { } else {
cloneCommand.call().close(); cloneCommand.call().close();
} }
return writeFile; return writeFile;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("", e);
throw new DinkyException(e); throw new DinkyException(e);
} }
} }
......
...@@ -44,29 +44,29 @@ spring: ...@@ -44,29 +44,29 @@ spring:
# 子配置项可以按需要打开或自定义配置 # 子配置项可以按需要打开或自定义配置
cache: cache:
type: simple type: simple
# # 如果type配置为redis,则该项可按需配置 # # 如果type配置为redis,则该项可按需配置
# redis: # redis:
## 是否缓存空值,保存默认即可 ## 是否缓存空值,保存默认即可
# cache-null-values: false # cache-null-values: false
## 缓存过期时间,24小时 ## 缓存过期时间,24小时
# time-to-live: 86400 # time-to-live: 86400
# redis: # redis:
# host: 119.3.184.208 # host: 119.3.184.208
# port: 6379 # port: 6379
# password: woai1998 # password: woai1998
# database: 10 # database: 10
# jedis: # jedis:
# pool: # pool:
# # 连接池最大连接数(使用负值表示没有限制) # # 连接池最大连接数(使用负值表示没有限制)
# max-active: 50 # max-active: 50
# # 连接池最大阻塞等待时间(使用负值表示没有限制) # # 连接池最大阻塞等待时间(使用负值表示没有限制)
# max-wait: 3000 # max-wait: 3000
# # 连接池中的最大空闲连接数 # # 连接池中的最大空闲连接数
# max-idle: 20 # max-idle: 20
# # 连接池中的最小空闲连接数 # # 连接池中的最小空闲连接数
# min-idle: 5 # min-idle: 5
# # 连接超时时间(毫秒) # # 连接超时时间(毫秒)
# timeout: 5000 # timeout: 5000
# file upload config of servlet , the default is 500MB # file upload config of servlet , the default is 500MB
servlet: servlet:
multipart: multipart:
...@@ -133,7 +133,7 @@ sa-token: ...@@ -133,7 +133,7 @@ sa-token:
timeout: 36000 timeout: 36000
# The temporary validity period of the token (the token will be considered as expired if there is no operation within the specified time) # The temporary validity period of the token (the token will be considered as expired if there is no operation within the specified time)
# unit: second , if you do not need to set a temporary token, you can set it to -1 # unit: second , if you do not need to set a temporary token, you can set it to -1
active-timeout: 1800 active-timeout: -1
# Whether to allow the same account to log in concurrently (when true, allow login together, when false, new login squeezes out old login) # Whether to allow the same account to log in concurrently (when true, allow login together, when false, new login squeezes out old login)
is-concurrent: false is-concurrent: false
# When multiple people log in to the same account, whether to share a token (if true, all logins share a token, and if false, create a new token for each login) # When multiple people log in to the same account, whether to share a token (if true, all logins share a token, and if false, create a new token for each login)
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<hamcrest.version>1.3</hamcrest.version> <hamcrest.version>1.3</hamcrest.version>
<hibernate-validator.version>6.2.0.Final</hibernate-validator.version> <hibernate-validator.version>6.2.0.Final</hibernate-validator.version>
<httpclient.version>4.5.13</httpclient.version> <httpclient.version>4.5.13</httpclient.version>
<hutool.version>5.8.25</hutool.version> <hutool.version>5.8.27</hutool.version>
<jackson.version>2.14.1</jackson.version> <jackson.version>2.14.1</jackson.version>
<jakarta.ws.rs-api.version>2.1.6</jakarta.ws.rs-api.version> <jakarta.ws.rs-api.version>2.1.6</jakarta.ws.rs-api.version>
<jasypt.version>1.9.3</jasypt.version> <jasypt.version>1.9.3</jasypt.version>
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<javax.mail>1.6.2</javax.mail> <javax.mail>1.6.2</javax.mail>
<jaxb.version>2.3.0</jaxb.version> <jaxb.version>2.3.0</jaxb.version>
<jedis.version>2.9.0</jedis.version> <jedis.version>2.9.0</jedis.version>
<jgit.version>5.13.2.202306221912-r</jgit.version> <jgit.version>5.13.3.202401111512-r</jgit.version>
<junit5.version>5.9.1</junit5.version> <junit5.version>5.9.1</junit5.version>
<knife4j.version>4.1.0</knife4j.version> <knife4j.version>4.1.0</knife4j.version>
<kubernetes-client.version>5.12.4</kubernetes-client.version> <kubernetes-client.version>5.12.4</kubernetes-client.version>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment