当前位置: 首页 > news >正文

做国外网站需要多少钱网页设计模板html代码百度云

做国外网站需要多少钱,网页设计模板html代码百度云,重庆网站建设平台免费,强生的网站建设原则​ 实现功能&#xff1a;借助jgit实现拉取文件&#xff0c;并返回文件路径清单 <!-- 依赖库 版本号有自行选择&#xff0c;只是需要注意支持的jdk版本即可&#xff0c;我使用的是jdk1.8--> <dependency><groupId>org.eclipse.jgit</groupId><artif…

​ 实现功能:借助jgit实现拉取文件,并返回文件路径清单

<!-- 依赖库 版本号有自行选择,只是需要注意支持的jdk版本即可,我使用的是jdk1.8-->
<dependency><groupId>org.eclipse.jgit</groupId><artifactId>org.eclipse.jgit</artifactId><version>5.13.2.202306221912-r</version>
</dependency>
// 还是用的 hutool和 lombok ,没有引入相关依赖的可以删除相关代码,使用类似代码替代。
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.PullResult;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.treewalk.CanonicalTreeParser;import javax.validation.constraints.NotNull;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;@Slf4j
public class GitUtil {/*** 克隆git库.* @param url* @param localPath*/public static void cloneRepository(String url, String localPath) {try {Git git = Git.cloneRepository().setURI(url).setDirectory(new File(localPath)).call();Repository repository = git.getRepository();repository.close();log.info("Cloned repository successfully from {} to {}", url, localPath);} catch (GitAPIException e) {log.error("Failed to clone repository from {} to {}", url, localPath, e);} catch (Exception e) {log.error("Failed to clone repository from {} to {}", url, localPath, e);}}/*** 初始化本地git库.* @param localPath*/public static void initRepository(String localPath) {try {Git git = Git.init().setDirectory(new File(localPath)).call();Repository repository = git.getRepository();repository.close();log.info("Initialized repository successfully at {}", localPath);} catch (GitAPIException e) {log.error("Failed to initialize repository at {}", localPath, e);} catch (Exception e) {log.error("Failed to initialize repository at {}", localPath, e);}}/*** 添加* @param git*/public static void addAll(Git git) {try {git.add().addFilepattern(".").call();log.info("Added all files to staging area");} catch (GitAPIException e) {log.error("Failed to add all files to staging area", e);} catch (Exception e) {log.error("Failed to add all files to staging area", e);}}/*** 提交* @param git* @param message*/public static void commit(Git git, String message) {try {git.commit().setMessage(message).call();log.info("Committed changes with message: {}", message);} catch (GitAPIException e) {log.error("Failed to commit changes with message: {}", message, e);} catch (Exception e) {log.error("Failed to commit changes with message: {}", message, e);}}/*** 依据本地目录获取本地git库* @param localPath* @return*/public static Repository getRepository(String localPath) {FileRepositoryBuilder builder = new FileRepositoryBuilder();try {return builder.setGitDir(new File(localPath + "/.git")).readEnvironment().findGitDir().build();} catch (Exception e) {log.error("Failed to open repository at {}", localPath, e);return null;}}private static CanonicalTreeParser getTreeByObjectId(Git git, ObjectId objectId) throws Exception {try (ObjectReader reader = git.getRepository().newObjectReader();) {CanonicalTreeParser treeIter = new CanonicalTreeParser();treeIter.reset(reader, objectId);return treeIter;}}private static String getChangeType(DiffEntry diffEntry) {if (StrUtil.equals("/dev/null", diffEntry.getNewPath())) {return "del";}if (StrUtil.equals("/dev/null", diffEntry.getOldPath())) {return "add";}return "update";}private static void addDiifToMap(@NotNull Map<String, List<String>> changeInfoMap, @NotNull DiffEntry diffEntry) {String changeType = getChangeType(diffEntry);List<String> fileNameList = changeInfoMap.get(changeType);if (fileNameList == null) {changeInfoMap.put(changeType, new ArrayList<>());fileNameList = changeInfoMap.get(changeType);}fileNameList.add(StrUtil.equals("del", changeType) ? diffEntry.getOldPath() : diffEntry.getNewPath());}/*** 拉取文件并返回拉取的文件清单* @param repository* @return 返回 del(删除)、add(新增)、update(更新)的文件清单*/public static Map<String, List<String>> pull(Repository repository) {Map<String, List<String>> changeInfoMap = new HashMap<>();try (Git git = new Git(repository);) {// 1.拉取前记录当前的版本号.FetchResult fetchResult = git.fetch().call();ObjectId oldHead = git.getRepository().resolve("HEAD^{tree}");// 2.拉取并记录拉取后的版本号PullResult result = git.pull().call();ObjectId newHead = git.getRepository().resolve("HEAD^{tree}");// 3.计算差异清单。List<DiffEntry> diffs = git.diff().setNewTree(getTreeByObjectId(git, newHead)).setOldTree(getTreeByObjectId(git, oldHead)).call();for (DiffEntry entry : diffs) {addDiifToMap(changeInfoMap,entry);}} catch (GitAPIException e) {log.error("Failed to pull changes from remote repository", e);} catch (Exception e) {log.error("Failed to pull changes from remote repository", e);}return changeInfoMap;}
}

使用方式:

1.	在将代码库拉取到本地的目录中(也可以通过上面的代码,直接从远程仓库克隆到本地目录中)
2.	使用pull方法即可针对指定目录的git库进行拉取并返回拉取的文件清单,以做其他用处。

以上仅为案例,实际功能还需要配合其他逻辑实现。

http://www.yayakq.cn/news/201874/

相关文章:

  • 快速做网站软件建设项目公告网站
  • 巩义网站建设方式优化wordpress 远程图片本地化
  • 上海网站建设中网站被降权的表现
  • 站长之家上海办公室装修设计公司
  • 做那个的网站wordpress直播播放器
  • 福州网站建设个人兼职聊城seo培训
  • 网站模板是什么黑群晖Wordpress
  • 购物网站功能介绍郑州做网站需要多少钱
  • 广州软件网站开发wordpress增加访问速度
  • 网站备案ip查询系统常用的cms建站系统
  • 网站开发与服务合同青岛网站开发费用
  • 网站备案基础知识凡科做网站的模版在哪儿找
  • 一般网站的服务器拓者设计吧邀请码免费
  • 自己做采集电影网站网站营销推广策划方案
  • 电脑怎么用别人的网站吗北京建网站公司飞沐
  • 网页编成网站网站建设公司发展理念
  • 高端网站设计平台百度百科优化排名
  • 网站app怎么做的免费做网站的网址有哪些
  • 做网站域名还重要吗云校招企业服务平台
  • ui设计网站做护肤品好的网站好
  • 网页制作工具可以发布网站吗服务器架构做网站
  • 网站怎么做的支付做小程序的公司
  • 长治制作公司网站的公司包装设计流程
  • 淮海中路街道网站建设环境设计专业必看网站
  • 荥阳网站建设荥阳高清做视频在线观看网站
  • 网站的后期维护工作一般做什么网站开发的思维导图
  • 网站开发背景怎么写免费的个人简历模板 医学生
  • 冠县网站建设多少钱数字化文化馆网站建设
  • 网站建设案例如何网站推广站群
  • wordpress自定义邮件模板下载地址网站搜索优化官网