提交 39b278fd authored 作者: chenshiying's avatar chenshiying

[新增] 统计代码开发行数

上级 fb7623ea
package com.loit.common.script;
import com.loit.common.script.dto.*;
import com.loit.common.utils.ListUtil;
import com.loit.common.utils.StringUtils;
import com.loit.common.utils.excel.ImportExcel;
import com.loit.common.utils.file.FileUtils;
import com.loit.common.utils.freemarker.FreeMarkerUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.entity.ContentType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Slf4j
public class GeneratorGitTjScript {
protected static String root_path = "F:\\9Git140\\loit-build-common\\loit-build-component\\loit-build-deploy-env\\src\\main\\resources\\bin";
/**
* 构建环境 生产或者 准生产
* TODO 构建前需修改环境
*/
private static BuildEnvEnum buildEnvEnum = BuildEnvEnum.PRODUCT;
protected static String root_path_full = root_path + "\\server" + "\\" + buildEnvEnum.getCode() ;
private static Map<String, FrontInstanceDto> frontInstanceDtoMap = new LinkedHashMap<>();
public static void main(String[] args) {
try {
//String filePathStr = Thread.currentThread().getContextClassLoader().getResource("deployInfo.xlsx").getPath();
String filePathStr = "F:\\9Git140\\loit-build-common\\loit-build-component\\loit-build-deploy-env\\src\\main\\resources\\deployInfo.xlsx";
File pdfFile = new File(filePathStr);
FileInputStream fileInputStream = new FileInputStream(pdfFile);
MultipartFile multipartFile = new MockMultipartFile(pdfFile.getName(), pdfFile.getName(),
ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
ImportExcel ei = new ImportExcel(multipartFile, 1, 0);
List<DeployInfoDataDTO> grayVersionDataDTOList = ei.getDataList(DeployInfoDataDTO.class);
if (ListUtil.isEmpty(grayVersionDataDTOList)) {
return;
}
for (DeployInfoDataDTO grayVersionDataDTO : grayVersionDataDTOList) {
if ("no".equals(grayVersionDataDTO.getDeployPath())) {
continue;
}
buildInitEnv(grayVersionDataDTO);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
/**
* 生成InitEnv
*
* @throws IOException
*/
private static void buildInitEnv(DeployInfoDataDTO grayVersionDataDTO) throws IOException {
File folder = new File(root_path_full);
if (!folder.exists()) {
folder.mkdirs();
}
String fixedIp = grayVersionDataDTO.getFixedIp();
if (StringUtils.isEmpty(fixedIp)) {
return;
}
String floatingIp = grayVersionDataDTO.getFloatingIp();
String replace = floatingIp.replaceAll("39.100.254.140","127.0.0.1");
Map model = new HashMap();
model.put("fl", grayVersionDataDTO.getFixedIp());
model.put("giturl", replace);
String nginxConfigShFileName = root_path_full + "\\gitTJ.sh";
String nginxConfigShResult = FreeMarkerUtils.process("sh"+ "\\" + buildEnvEnum.getCode() + "\\gittj.ftl", model);
FileUtils.appendNewLine(nginxConfigShFileName, nginxConfigShResult);
FileUtils.appendNewLine(nginxConfigShFileName, "########");
}
}
cd /root/loitsrc
git clone ${giturl}
cd ${fl}
git checkout -b dev origin/dev
cd /usr/local/src/gitstats
python gitstats.py /root/loitsrc/${fl} /root/test/${fl}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论