嗨,我正在使用 GitPull 方法将更改拉入存储库。
参考以下链接
http://cakebuild.net/api/Cake.Git/GitAliases/CC1AE32F
我需要在执行 GitPull 方法时获取更新文件的日志。
有什么方法可以使用下面的页面获取这些详细信息,或者建议其他方式在蛋糕中执行上述操作。
嗨,我正在使用 GitPull 方法将更改拉入存储库。
参考以下链接
http://cakebuild.net/api/Cake.Git/GitAliases/CC1AE32F
我需要在执行 GitPull 方法时获取更新文件的日志。
有什么方法可以使用下面的页面获取这些详细信息,或者建议其他方式在蛋糕中执行上述操作。
首先是免责声明,因为之前在 Cake.Git / Libgit2sharp 中存在合并问题,您需要升级到版本0.14.0
或更高版本Cake.Git
才能使此答案起作用。
无论是否快进合并,可靠地获取更改文件的最简单方法是:
Cake.Git
这样做的方法是
这可能如下所示
#addin nuget:?package=Cake.Git&version=0.14.0
DirectoryPath repoDir = MakeAbsolute(Directory("./Cake_Git"));
string name = "John Doe",
email = "john@doe.com";
var beforePullCommit = GitLogTip(repoDir);
var pullResult = GitPull(repoDir, name, email);
if (pullResult.Status!=GitMergeStatus.UpToDate)
{
var afterPullCommit = GitLogTip(repoDir);
var diff = GitDiff(repoDir, beforePullCommit.Sha, afterPullCommit.Sha);
foreach(var file in diff)
{
Information("{0}", file);
}
}
GitDiff返回具有这些属性的GitDiffFile的 ICollection。
Name Value Summary
Exists bool The file exists in the new side of the diff.
OldExists bool The file exists in the old side of the diff.
OldPath string The old path.
Path string The new path.
Status GitChangeKind The kind of change that has been done
(added, deleted, modified ...).
并且有一个 ToString() 覆盖 sp 这个脚本的输出看起来像这样
Path: ReleaseNotes.md, OldPath: ReleaseNotes.md, Status: Modified, Exists: True, OldExists: True
Path: src\Cake.Git\Cake.Git.csproj, OldPath: src\Cake.Git\Cake.Git.csproj, Status: Modified, Exists: True, OldExists: True
Path: src\Cake.Git\GitMergeResult.cs, OldPath: src\Cake.Git\GitMergeResult.cs, Status: Modified, Exists: True, OldExists: True
Path: src\Cake.Git\packages.config, OldPath: src\Cake.Git\packages.config, Status: Modified, Exists: True, OldExists: True
Path: src\SolutionInfo.cs, OldPath: src\SolutionInfo.cs, Status: Modified, Exists: True, OldExists: True
但由于它是一个类型化的对象,您当然可以以编程方式做更多的事情。
在执行 GitPull 方法时。
您可以在git pull (即 fetch 加合并)之后尝试(非蛋糕解决方案)
git log --stat
或者,正如Fun withFETCH_HEAD
git log --name-only ..FETCH_HEAD
我看不到Cake GitLog方法支持的那些选项,因此您至少可以尝试解析以下结果:
var result = GitLog("c:/temp/cake", 1);
(即由 生成的最后一次合并提交git pull
)