gpt4 book ai didi

c# - 验证 C# 项目的所有 Git 提交是否在重写历史后编译

转载 作者:太空狗 更新时间:2023-10-29 12:59:37 26 4
gpt4 key购买 nike

是否有任何自动化的方法来验证 Git 存储库中的所有提交都处于可编译状态?

我需要这个来验证我在重写历史后没有破坏任何东西。由于我正在重写历史记录,因此这不包括构建服务器 - 在提交时有效的提交可能在重写历史记录后被破坏。

例如,我有一个 Visual Studio 2015 C# 项目,我想象一些脚本如下:

git filter-branch --tree-filter msbuild

我希望它在每次提交时运行构建,并在构建过程返回非零值时停止并显示错误消息。

最佳答案

考虑到树过滤器将从 Git bash 执行命令,您可能想要使用

git filter-branch --tree-filter "MSBuild.exe" 

(确保您的 %PATH% 确实包含 c:\Program Files (x86)\MSBuild\14.0\Bin)
(或 use forward slash as in here)

这对 other option 同样有效提到in the comments

git rebase -i --exec MSBuild.exe <first sha you want to test>~

您可以使用 CMD session similar to this gist , 来自 Tim Abell :

@echo off
REM batch script for loading git-bash and the vs tools in the same window
REM inspiration: http://www.drrandom.org/post/2011/11/16/Grappling-with-multiple-remotes-in-git-tfs.aspx
REM screenshot: https://twitter.com/#!/tim_abell/status/199474387731226624/photo/1
%HOMEDRIVE%
cd %HOMEPATH%
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
echo Use full exe names when running under bash, e.g. "msbuild.exe"
echo Loading bash, you may now use git and msbuild in the same console \o/.
"C:\Program Files (x86)\Git\bin\sh.exe" --login -i

关于c# - 验证 C# 项目的所有 Git 提交是否在重写历史后编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39526311/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com