-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13999 from github/mbg/csharp/standalone/dotnet-ve…
…rsion C# Standalone: Install .NET SDK specified in `global.json`
- Loading branch information
Showing
10 changed files
with
136 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/Git.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
namespace Semmle.Extraction.CSharp.DependencyFetching | ||
{ | ||
/// <summary> | ||
/// Utilities for querying information from the git CLI. | ||
/// </summary> | ||
internal class Git | ||
{ | ||
private readonly ProgressMonitor progressMonitor; | ||
private const string git = "git"; | ||
|
||
public Git(ProgressMonitor progressMonitor) | ||
{ | ||
this.progressMonitor = progressMonitor; | ||
} | ||
|
||
/// <summary> | ||
/// Lists all files matching <paramref name="pattern"/> which are tracked in the | ||
/// current git repository. | ||
/// </summary> | ||
/// <param name="pattern">The file pattern.</param> | ||
/// <returns>A list of all tracked files which match <paramref name="pattern"/>.</returns> | ||
/// <exception cref="Exception"></exception> | ||
public List<string> ListFiles(string pattern) | ||
{ | ||
var results = new List<string>(); | ||
var args = string.Join(' ', "ls-files", $"\"{pattern}\""); | ||
|
||
progressMonitor.RunningProcess($"{git} {args}"); | ||
var pi = new ProcessStartInfo(git, args) | ||
{ | ||
UseShellExecute = false, | ||
RedirectStandardOutput = true | ||
}; | ||
|
||
using var p = new Process() { StartInfo = pi }; | ||
p.OutputDataReceived += new DataReceivedEventHandler((sender, e) => | ||
{ | ||
if (!string.IsNullOrWhiteSpace(e.Data)) | ||
{ | ||
results.Add(e.Data); | ||
} | ||
}); | ||
p.Start(); | ||
p.BeginOutputReadLine(); | ||
p.WaitForExit(); | ||
|
||
if (p.ExitCode != 0) | ||
{ | ||
progressMonitor.CommandFailed(git, args, p.ExitCode); | ||
throw new Exception($"{git} {args} failed"); | ||
} | ||
|
||
return results; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters