gpt4 book ai didi

c# - 在 ClearCase 中检索源文件的版本号

转载 作者:行者123 更新时间:2023-11-30 21:25:36 25 4
gpt4 key购买 nike

我创建了一个小插件来帮助我进行源代码管理。

有谁知道如何在 Rational ClearCase 中检索源文件的分支名称和版本号。我想使用 C# 来执行此操作。所有信息实际存储在哪里?

最佳答案

您需要从 C# 执行 cleartool 命令

更具体地说,一个带有 format optiondescr仅显示准确您所追求的内容。

cleartool descr -fmt "%Sn" youFileFullPath

这将返回一个类似/main/34的字符串,意思是/branch/version

System.Diagnostics.ProcessStartInfo psi =
new System.Diagnostics.ProcessStartInfo(@"cleartool");
psi.RedirectStandardOutput = true;
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psi.Arguments = "descr -fmt \"%Sn\" \"" + yourFilePath + "\"";
psi.UseShellExecute = false;
System.Diagnostics.Process monProcess;
monProcess= System.Diagnostics.Process.Start(psi);
System.IO.StreamReader myOutput = monProcess.StandardOutput;
monProcess.WaitForExit();
if (monProcess.HasExited)
{
//la sortie du process est recuperee dans un string
string output = myOutput.ReadToEnd();
MessageBox.Show(output);
}

注意:建议始终在文件完整路径周围使用双引号,以防路径或文件名包含空格


正如我在其他 ClearCase SO question 中所解释的那样, 你也可以使用 CAL interface (COM 对象),但我一直发现 cleartool(基本 CLI -- 命令行界面 --)更可靠,尤其是在出现问题时:错误消息更加准确。

关于c# - 在 ClearCase 中检索源文件的版本号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/548759/

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