Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static void LogException(Exception ex)
builder.Append($"App Start Time: {Process.GetCurrentProcess().StartTime}\n");
builder.Append($"Exception Time: {DateTime.Now}\n");
builder.Append($"Memory Usage: {Process.GetCurrentProcess().PrivateMemorySize64 / 1024 / 1024} MB\n");
builder.Append($"---------------------------\n\n");
builder.Append("---------------------------\n\n");
builder.Append(ex);

var time = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Branch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static string ShowCurrent(string repo)
var cmd = new Command();
cmd.WorkingDirectory = repo;
cmd.Context = repo;
cmd.Args = $"branch --show-current";
cmd.Args = "branch --show-current";
return cmd.ReadToEnd().StdOut.Trim();
}

Expand Down
16 changes: 5 additions & 11 deletions src/Commands/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,12 @@ private ProcessStartInfo CreateGitStartInfo()
}

// Force using this app as git editor.
switch (Editor)
start.Arguments += Editor switch
{
case EditorType.CoreEditor:
start.Arguments += $"-c core.editor=\"\\\"{selfExecFile}\\\" --core-editor\" ";
break;
case EditorType.RebaseEditor:
start.Arguments += $"-c core.editor=\"\\\"{selfExecFile}\\\" --rebase-message-editor\" -c sequence.editor=\"\\\"{selfExecFile}\\\" --rebase-todo-editor\" -c rebase.abbreviateCommands=true ";
break;
default:
start.Arguments += "-c core.editor=true ";
break;
}
EditorType.CoreEditor => $"-c core.editor=\"\\\"{selfExecFile}\\\" --core-editor\" ",
EditorType.RebaseEditor => $"-c core.editor=\"\\\"{selfExecFile}\\\" --rebase-message-editor\" -c sequence.editor=\"\\\"{selfExecFile}\\\" --rebase-todo-editor\" -c rebase.abbreviateCommands=true ",
_ => "-c core.editor=true ",
};

// Append command args
start.Arguments += Args;
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/QueryFileContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static Stream FromLFS(string repo, string oid, long size)
var starter = new ProcessStartInfo();
starter.WorkingDirectory = repo;
starter.FileName = Native.OS.GitExecutable;
starter.Arguments = $"lfs smudge";
starter.Arguments = "lfs smudge";
starter.UseShellExecute = false;
starter.CreateNoWindow = true;
starter.WindowStyle = ProcessWindowStyle.Hidden;
Expand Down
21 changes: 7 additions & 14 deletions src/Commands/QueryRevisionObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,14 @@ private void Parse(string line)
obj.Type = Models.ObjectType.Blob;
obj.Path = match.Groups[3].Value;

switch (match.Groups[1].Value)
obj.Type = match.Groups[1].Value switch
{
case "blob":
obj.Type = Models.ObjectType.Blob;
break;
case "tree":
obj.Type = Models.ObjectType.Tree;
break;
case "tag":
obj.Type = Models.ObjectType.Tag;
break;
case "commit":
obj.Type = Models.ObjectType.Commit;
break;
}
"blob" => Models.ObjectType.Blob,
"tree" => Models.ObjectType.Tree,
"tag" => Models.ObjectType.Tag,
"commit" => Models.ObjectType.Commit,
_ => obj.Type,
};

_objects.Add(obj);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/QueryStashes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public QueryStashes(string repo)
{
WorkingDirectory = repo;
Context = repo;
Args = $"stash list -z --no-show-signature --format=\"%H%n%P%n%ct%n%gd%n%B\"";
Args = "stash list -z --no-show-signature --format=\"%H%n%P%n%ct%n%gd%n%B\"";
}

public List<Models.Stash> Result()
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/SaveRevisionFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void Run(string repo, string revision, string file, string saveTo)
if (isLFSFiltered)
{
var pointerStream = QueryFileContent.Run(repo, revision, file);
ExecCmd(repo, $"lfs smudge", saveTo, pointerStream);
ExecCmd(repo, "lfs smudge", saveTo, pointerStream);
}
else
{
Expand Down
13 changes: 5 additions & 8 deletions src/Converters/FilterModeConverters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ public static class FilterModeConverters
public static readonly FuncValueConverter<Models.FilterMode, IBrush> ToBorderBrush =
new FuncValueConverter<Models.FilterMode, IBrush>(v =>
{
switch (v)
return v switch
{
case Models.FilterMode.Included:
return Brushes.Green;
case Models.FilterMode.Excluded:
return Brushes.Red;
default:
return Brushes.Transparent;
}
Models.FilterMode.Included => Brushes.Green,
Models.FilterMode.Excluded => Brushes.Red,
_ => Brushes.Transparent,
};
});
}
}
41 changes: 9 additions & 32 deletions src/Converters/InteractiveRebaseActionConverters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,19 @@ public static class InteractiveRebaseActionConverters
public static readonly FuncValueConverter<Models.InteractiveRebaseAction, IBrush> ToIconBrush =
new FuncValueConverter<Models.InteractiveRebaseAction, IBrush>(v =>
{
switch (v)
return v switch
{
case Models.InteractiveRebaseAction.Pick:
return Brushes.Green;
case Models.InteractiveRebaseAction.Edit:
return Brushes.Orange;
case Models.InteractiveRebaseAction.Reword:
return Brushes.Orange;
case Models.InteractiveRebaseAction.Squash:
return Brushes.LightGray;
case Models.InteractiveRebaseAction.Fixup:
return Brushes.LightGray;
default:
return Brushes.Red;
}
Models.InteractiveRebaseAction.Pick => Brushes.Green,
Models.InteractiveRebaseAction.Edit => Brushes.Orange,
Models.InteractiveRebaseAction.Reword => Brushes.Orange,
Models.InteractiveRebaseAction.Squash => Brushes.LightGray,
Models.InteractiveRebaseAction.Fixup => Brushes.LightGray,
_ => Brushes.Red,
};
});

public static readonly FuncValueConverter<Models.InteractiveRebaseAction, string> ToName =
new FuncValueConverter<Models.InteractiveRebaseAction, string>(v =>
{
switch (v)
{
case Models.InteractiveRebaseAction.Pick:
return "Pick";
case Models.InteractiveRebaseAction.Edit:
return "Edit";
case Models.InteractiveRebaseAction.Reword:
return "Reword";
case Models.InteractiveRebaseAction.Squash:
return "Squash";
case Models.InteractiveRebaseAction.Fixup:
return "Fixup";
default:
return "Drop";
}
});
new FuncValueConverter<Models.InteractiveRebaseAction, string>(v => v.ToString());

public static readonly FuncValueConverter<Models.InteractiveRebaseAction, bool> CanEditMessage =
new FuncValueConverter<Models.InteractiveRebaseAction, bool>(v => v == Models.InteractiveRebaseAction.Reword || v == Models.InteractiveRebaseAction.Squash);
Expand Down
2 changes: 1 addition & 1 deletion src/Models/AvatarManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void SetFromLocal(string email, string file)
{
try
{
Bitmap image = null;
Bitmap image;

using (var stream = File.OpenRead(file))
{
Expand Down
48 changes: 16 additions & 32 deletions src/Models/CommitSignInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,31 @@ public IBrush Brush
{
get
{
switch (VerifyResult)
return VerifyResult switch
{
case 'G':
case 'U':
return Brushes.Green;
case 'X':
case 'Y':
case 'R':
return Brushes.DarkOrange;
case 'B':
case 'E':
return Brushes.Red;
default:
return Brushes.Transparent;
}
'G' or 'U' => Brushes.Green,
'X' or 'Y' or 'R' => Brushes.DarkOrange,
'B' or 'E' => Brushes.Red,
_ => Brushes.Transparent,
};
}
}

public string ToolTip
{
get
{
switch (VerifyResult)
return VerifyResult switch
{
case 'G':
return "Good signature.";
case 'U':
return "Good signature with unknown validity.";
case 'X':
return "Good signature but has expired.";
case 'Y':
return "Good signature made by expired key.";
case 'R':
return "Good signature made by a revoked key.";
case 'B':
return "Bad signature.";
case 'E':
return "Signature cannot be checked.";
default:
return "No signature.";
}
'G' => "Good signature.",
'U' => "Good signature with unknown validity.",
'X' => "Good signature but has expired.",
'Y' => "Good signature made by expired key.",
'R' => "Good signature made by a revoked key.",
'B' => "Bad signature.",
'E' => "Signature cannot be checked.",
_ => "No signature.",
};
}
}
}
Expand Down
12 changes: 3 additions & 9 deletions src/Models/DiffResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public TextDiffSelection MakeSelection(int startLine, int endLine, bool isCombin
rs.HasChanges = true;
break;
}
else if (isOldSide)
if (isOldSide)
{
rs.HasLeftChanges = true;
}
Expand All @@ -116,7 +116,7 @@ public TextDiffSelection MakeSelection(int startLine, int endLine, bool isCombin
rs.HasChanges = true;
break;
}
else if (isOldSide)
if (isOldSide)
{
rs.HasChanges = true;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ public void GenerateNewPatchFromSelection(Change change, string fileBlobGuid, Te
if (revert)
{
var totalLines = Lines.Count - 1;
builder.Append($"@@ -0,").Append(totalLines - additions).Append(" +0,").Append(totalLines).Append(" @@");
builder.Append("@@ -0,").Append(totalLines - additions).Append(" +0,").Append(totalLines).Append(" @@");
for (int i = 1; i <= totalLines; i++)
{
var line = Lines[i];
Expand Down Expand Up @@ -645,12 +645,6 @@ public class ImageDiff

public class NoOrEOLChange;

public class FileModeDiff
{
public string Old { get; set; } = string.Empty;
public string New { get; set; } = string.Empty;
}

public class SubmoduleDiff
{
public RevisionSubmodule Old { get; set; } = null;
Expand Down
16 changes: 6 additions & 10 deletions src/Models/GitFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,13 @@ public bool IsValid

public string GetPrefix(GitFlowBranchType type)
{
switch (type)
return type switch
{
case GitFlowBranchType.Feature:
return FeaturePrefix;
case GitFlowBranchType.Release:
return ReleasePrefix;
case GitFlowBranchType.Hotfix:
return HotfixPrefix;
default:
return string.Empty;
}
GitFlowBranchType.Feature => FeaturePrefix,
GitFlowBranchType.Release => ReleasePrefix,
GitFlowBranchType.Hotfix => HotfixPrefix,
_ => string.Empty,
};
}
}
}
16 changes: 4 additions & 12 deletions src/Models/OpenAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,10 @@ public void Chat(string prompt, string question, CancellationToken cancellation,
{
var server = new Uri(_server);
var key = new ApiKeyCredential(_apiKey);
var client = null as ChatClient;
if (_server.Contains("openai.azure.com/", StringComparison.Ordinal))
{
var azure = new AzureOpenAIClient(server, key);
client = azure.GetChatClient(_model);
}
else
{
var openai = new OpenAIClient(key, new() { Endpoint = server });
client = openai.GetChatClient(_model);
}

var oaiClient = _server.Contains("openai.azure.com/", StringComparison.Ordinal)
? new AzureOpenAIClient(server, key)
: new OpenAIClient(key, new() { Endpoint = server });
var client = oaiClient.GetChatClient(_model);
var messages = new List<ChatMessage>();
messages.Add(_model.Equals("o1-mini", StringComparison.Ordinal) ? new UserChatMessage(prompt) : new SystemChatMessage(prompt));
messages.Add(new UserChatMessage(question));
Expand Down
22 changes: 8 additions & 14 deletions src/Native/MacOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,15 @@ public string FindGitExecutable()

public string FindTerminal(Models.ShellOrTerminal shell)
{
switch (shell.Type)
return shell.Type switch
{
case "mac-terminal":
return "Terminal";
case "iterm2":
return "iTerm";
case "warp":
return "Warp";
case "ghostty":
return "Ghostty";
case "kitty":
return "kitty";
}

return string.Empty;
"mac-terminal" => "Terminal",
"iterm2" => "iTerm",
"warp" => "Warp",
"ghostty" => "Ghostty",
"kitty" => "kitty",
_ => string.Empty,
};
}

public List<Models.ExternalTool> FindExternalTools()
Expand Down
2 changes: 1 addition & 1 deletion src/Native/OS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static void OpenBrowser(string url)
public static void OpenTerminal(string workdir)
{
if (string.IsNullOrEmpty(ShellOrTerminal))
App.RaiseException(workdir, $"Terminal is not specified! Please confirm that the correct shell/terminal has been configured.");
App.RaiseException(workdir, "Terminal is not specified! Please confirm that the correct shell/terminal has been configured.");
else
_backend.OpenTerminal(workdir);
}
Expand Down
Loading
Loading