Skip to content

Commit

Permalink
[Fix]fix git bug (DataLinkDC#3429)
Browse files Browse the repository at this point in the history
Co-authored-by: zackyoungh <zackyoungh@users.noreply.github.com>
  • Loading branch information
zackyoungh and zackyoungh authored Apr 26, 2024
1 parent d30910f commit fffe53e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 45 deletions.
6 changes: 6 additions & 0 deletions dinky-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@
<dependency>
<groupId>org.dromara.sms4j</groupId>
<artifactId>sms4j-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>cn.hutool</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand Down
41 changes: 22 additions & 19 deletions dinky-admin/src/main/java/org/dinky/utils/GitRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.LsRemoteCommand;
import org.eclipse.jgit.api.PullCommand;
import org.eclipse.jgit.api.TransportCommand;
import org.eclipse.jgit.api.TransportConfigCallback;
import org.eclipse.jgit.api.errors.GitAPIException;
Expand Down Expand Up @@ -95,7 +96,6 @@ public File cloneAndPull(String projectName, String branch, File logFile, Consum
FileUtil.mkdir(targetFile);
File writeFile = new File(targetFile, branch);

Git git;
try {

CloneCommand cloneCommand =
Expand All @@ -109,30 +109,33 @@ public File cloneAndPull(String projectName, String branch, File logFile, Consum
.readEnvironment()
.findGitDir()
.build();
git = new Git(repository);
git.pull()
.setProgressMonitor(new TextProgressMonitor(new StringWriter() {
@Override
public void write(String str) {
if (logFile != null) {
FileUtil.appendUtf8String(str, logFile);
}
if (consumer != null) {
consumer.accept(str);
}
System.out.println(str);
super.write(str);
try (Git git = new Git(repository)) {
PullCommand pullCommand = git.pull().setProgressMonitor(new TextProgressMonitor(new StringWriter() {
@Override
public void write(String str) {
if (logFile != null) {
FileUtil.appendUtf8String(str, logFile);
}
}))
.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password))
.call();
git.close();
if (consumer != null) {
consumer.accept(str);
}
log.info(str);
super.write(str);
}
}));
if (!StrUtil.hasBlank(username, password)) {
pullCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password));
}

pullCommand.call();
}

} else {
cloneCommand.call().close();
}
return writeFile;
} catch (Exception e) {
e.printStackTrace();
log.error("", e);
throw new DinkyException(e);
}
}
Expand Down
48 changes: 24 additions & 24 deletions dinky-admin/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,29 @@ spring:
# 子配置项可以按需要打开或自定义配置
cache:
type: simple
# # 如果type配置为redis,则该项可按需配置
# redis:
## 是否缓存空值,保存默认即可
# cache-null-values: false
## 缓存过期时间,24小时
# time-to-live: 86400
# redis:
# host: 119.3.184.208
# port: 6379
# password: woai1998
# database: 10
# jedis:
# pool:
# # 连接池最大连接数(使用负值表示没有限制)
# max-active: 50
# # 连接池最大阻塞等待时间(使用负值表示没有限制)
# max-wait: 3000
# # 连接池中的最大空闲连接数
# max-idle: 20
# # 连接池中的最小空闲连接数
# min-idle: 5
# # 连接超时时间(毫秒)
# timeout: 5000
# # 如果type配置为redis,则该项可按需配置
# redis:
## 是否缓存空值,保存默认即可
# cache-null-values: false
## 缓存过期时间,24小时
# time-to-live: 86400
# redis:
# host: 119.3.184.208
# port: 6379
# password: woai1998
# database: 10
# jedis:
# pool:
# # 连接池最大连接数(使用负值表示没有限制)
# max-active: 50
# # 连接池最大阻塞等待时间(使用负值表示没有限制)
# max-wait: 3000
# # 连接池中的最大空闲连接数
# max-idle: 20
# # 连接池中的最小空闲连接数
# min-idle: 5
# # 连接超时时间(毫秒)
# timeout: 5000
# file upload config of servlet , the default is 500MB
servlet:
multipart:
Expand Down Expand Up @@ -133,7 +133,7 @@ sa-token:
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)
# 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)
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)
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<hamcrest.version>1.3</hamcrest.version>
<hibernate-validator.version>6.2.0.Final</hibernate-validator.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>
<jakarta.ws.rs-api.version>2.1.6</jakarta.ws.rs-api.version>
<jasypt.version>1.9.3</jasypt.version>
Expand All @@ -77,7 +77,7 @@
<javax.mail>1.6.2</javax.mail>
<jaxb.version>2.3.0</jaxb.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>
<knife4j.version>4.1.0</knife4j.version>
<kubernetes-client.version>5.12.4</kubernetes-client.version>
Expand Down

0 comments on commit fffe53e

Please sign in to comment.