chore: initial project setup

This commit is contained in:
liu
2026-02-03 23:24:32 +08:00
commit 28b517da40
32 changed files with 3776 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
package com.svnmanager.service;
import com.svnmanager.util.ProcessUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeoutException;
/**
* Diff服务
*/
public class DiffService extends SvnService {
private static final Logger logger = LoggerFactory.getLogger(DiffService.class);
/**
* 获取差异
*
* @param workingDirectory 工作目录
* @param filePath 文件路径null表示所有文件
* @return 差异内容
* @throws IOException IO异常
* @throws InterruptedException 中断异常
* @throws TimeoutException 超时异常
*/
public String getDiff(String workingDirectory, String filePath)
throws IOException, InterruptedException, TimeoutException {
logger.debug("获取差异: {}", workingDirectory);
if (!isValidWorkingCopy(workingDirectory)) {
throw new IllegalArgumentException("无效的SVN工作副本: " + workingDirectory);
}
List<String> args = new ArrayList<>();
if (filePath != null && !filePath.isEmpty()) {
args.add(filePath);
}
ProcessUtil.ProcessResult result = executeSvnCommand("diff", args, workingDirectory);
if (result.isSuccess()) {
return result.getOutputAsString();
} else {
logger.warn("获取差异失败: {}", result.getErrorAsString());
return result.getErrorAsString();
}
}
/**
* 获取所有文件的差异
*
* @param workingDirectory 工作目录
* @return 差异内容
* @throws IOException IO异常
* @throws InterruptedException 中断异常
* @throws TimeoutException 超时异常
*/
public String getDiff(String workingDirectory)
throws IOException, InterruptedException, TimeoutException {
return getDiff(workingDirectory, null);
}
}