你好,我正在使用GitPull方法将更改拉入存储库。
参考下面的链接
http://cakebuild.net/api/Cake.Git/GitAliases/CC1AE32F
在执行GitPull方法时,我需要获取更新文件的日志。
是否可以使用下面的页面获取这些详细信息,或建议在Cake中执行上述操作的其他方法。
你好,我正在使用GitPull方法将更改拉入存储库。
参考下面的链接
http://cakebuild.net/api/Cake.Git/GitAliases/CC1AE32F
在执行GitPull方法时,我需要获取更新文件的日志。
是否可以使用下面的页面获取这些详细信息,或建议在Cake中执行上述操作的其他方法。
Cake.Git
版本为0.14.0
或更高版本才能使本回答有效。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 集合,该集合具有以下属性。
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 ...).
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
但由于它是一个类型化对象,你当然可以在程序中做更多的事情。
git log --stat
或者,如同在与FETCH_HEAD
玩耍中所提到的
git log --name-only ..FETCH_HEAD
我没有看到Cake GitLog方法支持这些选项,所以你可以尝试解析以下结果:
var result = GitLog("c:/temp/cake", 1);
git pull
生成的最后一次合并提交)
git clean -xdf
命令时,它可以正常工作,甚至git pull stat
也可以正常工作。但是在尝试写日志时遇到了上述问题。 - Jeeva Svar startInfo = new ProcessStartInfo();
startInfo.WorkingDirectory = // 工作目录
// 设置其他属性
Process proc = Process.Start(startInfo);
- VonCvar startInfo = new ProcessStartInfo(); startInfo.WorkingDirectory = @"G:\Gitlab\sfinput-xaml"; startInfo.Arguments= "pull --stat >../GitLogs/log.txt"; startInfo.FileName = "Git"; Process proc = Process.Start(startInfo);
- Jeeva S