mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-24 02:40:24 +08:00
code_style: a few more to PR #1543
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -618,8 +618,7 @@ namespace SourceGit
|
||||
try
|
||||
{
|
||||
// Fetch latest release information.
|
||||
using var client = new HttpClient();
|
||||
client.Timeout = TimeSpan.FromSeconds(5);
|
||||
using var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(5) };
|
||||
var data = await client.GetStringAsync("https://sourcegit-scm.github.io/data/version.json");
|
||||
|
||||
// Parse JSON into Models.Version.
|
||||
|
||||
@@ -55,9 +55,9 @@ namespace SourceGit.Commands
|
||||
Log?.AppendLine($"$ git {Args}\n");
|
||||
|
||||
var errs = new List<string>();
|
||||
|
||||
using var proc = new Process();
|
||||
proc.StartInfo = CreateGitStartInfo(true);
|
||||
|
||||
proc.OutputDataReceived += (_, e) => HandleOutput(e.Data, errs);
|
||||
proc.ErrorDataReceived += (_, e) => HandleOutput(e.Data, errs);
|
||||
|
||||
@@ -129,8 +129,7 @@ namespace SourceGit.Commands
|
||||
|
||||
protected async Task<Result> ReadToEndAsync()
|
||||
{
|
||||
using var proc = new Process();
|
||||
proc.StartInfo = CreateGitStartInfo(true);
|
||||
using var proc = new Process() { StartInfo = CreateGitStartInfo(true) };
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -24,14 +24,13 @@ namespace SourceGit.Commands
|
||||
using var proc = Process.Start(starter);
|
||||
await proc.StandardOutput.BaseStream.CopyToAsync(stream).ConfigureAwait(false);
|
||||
await proc.WaitForExitAsync().ConfigureAwait(false);
|
||||
|
||||
stream.Position = 0;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
App.RaiseException(repo, $"Failed to query file content: {e}");
|
||||
}
|
||||
|
||||
stream.Position = 0;
|
||||
return stream;
|
||||
}
|
||||
|
||||
@@ -56,14 +55,13 @@ namespace SourceGit.Commands
|
||||
await proc.StandardInput.WriteLineAsync($"size {size}").ConfigureAwait(false);
|
||||
await proc.StandardOutput.BaseStream.CopyToAsync(stream).ConfigureAwait(false);
|
||||
await proc.WaitForExitAsync().ConfigureAwait(false);
|
||||
|
||||
stream.Position = 0;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
App.RaiseException(repo, $"Failed to query file content: {e}");
|
||||
}
|
||||
|
||||
stream.Position = 0;
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +43,15 @@ namespace SourceGit.Commands
|
||||
try
|
||||
{
|
||||
using var proc = Process.Start(starter);
|
||||
|
||||
if (input != null)
|
||||
await proc.StandardInput.WriteAsync(await new StreamReader(input).ReadToEndAsync());
|
||||
await proc.StandardOutput.BaseStream.CopyToAsync(sw);
|
||||
await proc.WaitForExitAsync();
|
||||
{
|
||||
var inputString = await new StreamReader(input).ReadToEndAsync().ConfigureAwait(false);
|
||||
await proc.StandardInput.WriteAsync(inputString).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await proc.StandardOutput.BaseStream.CopyToAsync(sw).ConfigureAwait(false);
|
||||
await proc.WaitForExitAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -48,13 +48,14 @@ namespace SourceGit.Native
|
||||
|
||||
public List<Models.ExternalTool> FindExternalTools()
|
||||
{
|
||||
var localAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
var finder = new Models.ExternalToolsFinder();
|
||||
finder.VSCode(() => FindExecutable("code"));
|
||||
finder.VSCodeInsiders(() => FindExecutable("code-insiders"));
|
||||
finder.VSCodium(() => FindExecutable("codium"));
|
||||
finder.Cursor(() => FindExecutable("cursor"));
|
||||
finder.Fleet(FindJetBrainsFleet);
|
||||
finder.FindJetBrainsFromToolbox(() => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "JetBrains/Toolbox"));
|
||||
finder.Fleet(() => FindJetBrainsFleet(localAppDataDir));
|
||||
finder.FindJetBrainsFromToolbox(() => Path.Combine(localAppDataDir, "JetBrains/Toolbox"));
|
||||
finder.SublimeText(() => FindExecutable("subl"));
|
||||
finder.Zed(() => FindExecutable("zeditor"));
|
||||
return finder.Tools;
|
||||
@@ -132,9 +133,9 @@ namespace SourceGit.Native
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string FindJetBrainsFleet()
|
||||
private string FindJetBrainsFleet(string localAppDataDir)
|
||||
{
|
||||
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "JetBrains/Toolbox/apps/fleet/bin/Fleet");
|
||||
var path = Path.Combine(localAppDataDir, "JetBrains/Toolbox/apps/fleet/bin/Fleet");
|
||||
return File.Exists(path) ? path : FindExecutable("fleet");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,13 +70,14 @@ namespace SourceGit.Native
|
||||
|
||||
public List<Models.ExternalTool> FindExternalTools()
|
||||
{
|
||||
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
var finder = new Models.ExternalToolsFinder();
|
||||
finder.VSCode(() => "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code");
|
||||
finder.VSCodeInsiders(() => "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code");
|
||||
finder.VSCodium(() => "/Applications/VSCodium.app/Contents/Resources/app/bin/codium");
|
||||
finder.Cursor(() => "/Applications/Cursor.app/Contents/Resources/app/bin/cursor");
|
||||
finder.Fleet(() => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Applications/Fleet.app/Contents/MacOS/Fleet"));
|
||||
finder.FindJetBrainsFromToolbox(() => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library/Application Support/JetBrains/Toolbox"));
|
||||
finder.Fleet(() => Path.Combine(home, "Applications/Fleet.app/Contents/MacOS/Fleet"));
|
||||
finder.FindJetBrainsFromToolbox(() => Path.Combine(home, "Library/Application Support/JetBrains/Toolbox"));
|
||||
finder.SublimeText(() => "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl");
|
||||
finder.Zed(() => File.Exists("/usr/local/bin/zed") ? "/usr/local/bin/zed" : "/Applications/Zed.app/Contents/MacOS/cli");
|
||||
return finder.Tools;
|
||||
|
||||
@@ -180,13 +180,14 @@ namespace SourceGit.Native
|
||||
|
||||
public List<Models.ExternalTool> FindExternalTools()
|
||||
{
|
||||
var localAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
var finder = new Models.ExternalToolsFinder();
|
||||
finder.VSCode(FindVSCode);
|
||||
finder.VSCodeInsiders(FindVSCodeInsiders);
|
||||
finder.VSCodium(FindVSCodium);
|
||||
finder.Cursor(FindCursor);
|
||||
finder.Fleet(() => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Programs\Fleet\Fleet.exe"));
|
||||
finder.FindJetBrainsFromToolbox(() => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"JetBrains\Toolbox"));
|
||||
finder.Fleet(() => Path.Combine(localAppDataDir, @"Programs\Fleet\Fleet.exe"));
|
||||
finder.FindJetBrainsFromToolbox(() => Path.Combine(localAppDataDir, @"JetBrains\Toolbox"));
|
||||
finder.SublimeText(FindSublimeText);
|
||||
finder.TryAdd("Visual Studio", "vs", FindVisualStudio, GenerateCommandlineArgsForVisualStudio);
|
||||
return finder.Tools;
|
||||
|
||||
@@ -77,19 +77,19 @@ namespace SourceGit.ViewModels
|
||||
builder.Append(": ");
|
||||
|
||||
builder.Append(_description);
|
||||
builder.AppendLine("\n");
|
||||
builder.AppendLine().AppendLine();
|
||||
|
||||
if (!string.IsNullOrEmpty(_detail))
|
||||
{
|
||||
builder.Append(_detail);
|
||||
builder.AppendLine("\n");
|
||||
builder.AppendLine().AppendLine();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(_breakingChanges))
|
||||
{
|
||||
builder.Append("BREAKING CHANGE: ");
|
||||
builder.Append(_breakingChanges);
|
||||
builder.AppendLine("\n");
|
||||
builder.AppendLine().AppendLine();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(_closedIssue))
|
||||
|
||||
@@ -250,8 +250,7 @@ namespace SourceGit.ViewModels
|
||||
start.StandardErrorEncoding = Encoding.UTF8;
|
||||
start.WorkingDirectory = _repo.FullPath;
|
||||
|
||||
using var proc = new Process();
|
||||
proc.StartInfo = start;
|
||||
using var proc = new Process() { StartInfo = start };
|
||||
var builder = new StringBuilder();
|
||||
|
||||
proc.OutputDataReceived += (_, e) =>
|
||||
|
||||
@@ -272,6 +272,7 @@ namespace SourceGit.ViewModels
|
||||
_repo.CheckoutBranch(b);
|
||||
return;
|
||||
}
|
||||
|
||||
if (d.Type == Models.DecoratorType.RemoteBranchHead)
|
||||
{
|
||||
var rb = _repo.Branches.Find(x => x.FriendlyName == d.Name);
|
||||
|
||||
Reference in New Issue
Block a user