Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f716c5e

Browse files
refactor: use existing QueryFileContent command
Signed-off-by: leo <longshuang@msn.cn>
1 parent ed496a4 commit f716c5e

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

‎src/Commands/SaveRevisionFile.cs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ public static void Run(string repo, string revision, string file, string saveTo)
1313
var isLFSFiltered = new IsLFSFiltered(repo, revision, file).Result();
1414
if (isLFSFiltered)
1515
{
16-
var tmpFile = saveTo + ".tmp";
17-
if (ExecCmd(repo, $"show {revision}:\"{file}\"", tmpFile))
18-
{
19-
ExecCmd(repo, $"lfs smudge", saveTo, tmpFile);
20-
}
21-
File.Delete(tmpFile);
16+
var pointerStream = QueryFileContent.Run(repo, revision, file);
17+
ExecCmd(repo, $"lfs smudge", saveTo, pointerStream);
2218
}
2319
else
2420
{
2521
ExecCmd(repo, $"show {revision}:\"{file}\"", saveTo);
2622
}
2723
}
2824

29-
private static bool ExecCmd(string repo, string args, string outputFile, stringinputFile = null)
25+
private static bool ExecCmd(string repo, string args, string outputFile, Streaminput = null)
3026
{
3127
var starter = new ProcessStartInfo();
3228
starter.WorkingDirectory = repo;
@@ -45,21 +41,8 @@ private static bool ExecCmd(string repo, string args, string outputFile, string
4541
{
4642
var proc = new Process() { StartInfo = starter };
4743
proc.Start();
48-
49-
if (inputFile != null)
50-
{
51-
using (StreamReader sr = new StreamReader(inputFile))
52-
{
53-
while (true)
54-
{
55-
var line = sr.ReadLine();
56-
if (line == null)
57-
break;
58-
proc.StandardInput.WriteLine(line);
59-
}
60-
}
61-
}
62-
44+
if (input != null)
45+
proc.StandardInput.Write(new StreamReader(input).ReadToEnd());
6346
proc.StandardOutput.BaseStream.CopyTo(sw);
6447
proc.WaitForExit();
6548
var rs = proc.ExitCode == 0;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /