Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspect
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
inspect
Commits
cf3668b4
提交
cf3668b4
authored
3月 09, 2020
作者:
czq
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of git.yfzx.zjtys.com.cn:912-system/monitor/inspect into czq
上级
229a1711
809d6dae
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
7 行增加
和
29 行删除
+7
-29
InspectController.java
...n/java/com/zjty/inspect/controller/InspectController.java
+3
-23
GitLabUtil.java
src/main/java/com/zjty/inspect/utils/GitLabUtil.java
+4
-6
没有找到文件。
src/main/java/com/zjty/inspect/controller/InspectController.java
浏览文件 @
cf3668b4
...
...
@@ -116,26 +116,6 @@ public class InspectController {
return
ResponseEntity
.
ok
(
inspect
);
}
/**
* git下载代码进行评估
*
* @param inspectParameter 封装
* @return
*/
@PostMapping
(
"/git"
)
@ApiOperation
(
"git下载代码进行评估"
)
public
ResponseEntity
inspect1
(
@RequestBody
InspectParameter
inspectParameter
)
{
String
path
=
GitLabUtil
.
downLoadProject
(
inspectParameter
.
getGitAddress
());
inspectParameter
.
setId
(
UUIDUtil
.
getUUID
());
inspectParameter
.
setSourceAddress
(
path
);
ReportVo
reportVo
=
new
ReportVo
();
reportVo
.
setUploadType
(
"git下载"
);
reportVo
.
setSourceAddress
(
path
);
reportVo
.
setGitAddress
(
inspectParameter
.
getGitAddress
());
ReportVo
inspect
=
inspectService
.
inspect
(
reportVo
,
inspectParameter
);
return
ResponseEntity
.
ok
(
inspect
);
}
@PostMapping
(
"/frontend"
)
@ApiOperation
(
"git下载代码进行评估"
)
public
ResponseEntity
inspect
(
MultipartFile
file
)
throws
IOException
{
...
...
@@ -379,7 +359,7 @@ public class InspectController {
}
@PostMapping
(
"/uploads"
)
private
ResponseEntity
uploads
(
@RequestParam
(
value
=
"file"
)
MultipartFile
multfile
){
private
ResponseEntity
uploads
(
@RequestParam
(
value
=
"file"
)
MultipartFile
multfile
,
String
s
){
try
{
File
file
=
FileUtil
.
saveToLocal
(
multfile
);
String
name
=
file
.
getName
();
...
...
@@ -391,8 +371,8 @@ public class InspectController {
}
}
@PostMapping
(
"/gitdownload"
)
private
ResponseEntity
gitDownloads
(
String
gitAddress
){
String
gitPath
=
GitLabUtil
.
downLoadProject
(
gitAddress
);
private
ResponseEntity
gitDownloads
(
String
gitAddress
,
String
username
,
String
password
){
String
gitPath
=
GitLabUtil
.
downLoadProject
(
gitAddress
,
username
,
password
);
return
ResponseEntity
.
ok
(
gitPath
);
}
}
src/main/java/com/zjty/inspect/utils/GitLabUtil.java
浏览文件 @
cf3668b4
...
...
@@ -3,6 +3,7 @@ package com.zjty.inspect.utils;
import
org.eclipse.jgit.api.CloneCommand
;
import
org.eclipse.jgit.api.Git
;
import
org.eclipse.jgit.api.errors.GitAPIException
;
import
org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
...
...
@@ -16,7 +17,7 @@ import java.time.LocalDate;
@Component
public
class
GitLabUtil
{
public
static
String
downLoadProject
(
String
path
)
{
public
static
String
downLoadProject
(
String
path
,
String
username
,
String
password
)
{
String
name1
=
LocalDate
.
now
().
toString
();
String
[]
split1
=
UUIDUtil
.
getUUID
().
split
(
"-"
);
//String REMOTE_URL = "https://git.yfzx.zjtys.com.cn:8888/912-system/monitor/adaptation-master.git";
...
...
@@ -25,7 +26,9 @@ public class GitLabUtil {
File
file
=
new
File
(
"./"
+
name1
+
"/"
+
split1
[
0
]+
"/"
);
file
.
mkdirs
();
cloneCommand
.
setDirectory
(
file
);
cloneCommand
.
setCredentialsProvider
(
new
UsernamePasswordCredentialsProvider
(
username
,
password
));
try
{
cloneCommand
.
call
();
}
catch
(
GitAPIException
e
)
{
e
.
printStackTrace
();
...
...
@@ -38,11 +41,6 @@ public class GitLabUtil {
return
file
.
getAbsolutePath
();
}
public
static
void
main
(
String
[]
args
)
{
String
hostsss
=
GitLabUtil
.
downLoadProject
(
"https://git.yfzx.zjtys.com.cn/912-system/monitor/inspect.git"
);
System
.
out
.
println
(
hostsss
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论