Skip to content

Commit

Permalink
fix: Do not error out if remote missing
Browse files Browse the repository at this point in the history
  • Loading branch information
twpol committed Nov 27, 2024
1 parent 79c68e1 commit c2b4c10
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Git/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Init(string repository)
if (!Directory.Exists(GitPath)) Directory.CreateDirectory(GitPath);
if (!File.Exists(Path.Join(GitPath, ".git", "config"))) RunCommand($"init");

RunCommand($"config remove-section remote.origin");
RunCommandIgnoreErrors($"config remove-section remote.origin");
RunCommand($"remote add origin --mirror=fetch {repository}");
}

Expand Down Expand Up @@ -137,6 +137,18 @@ public void SetBranchRef(string branch, string reference)
RunCommand($"branch -f {branch} {reference}");
}

void RunCommandIgnoreErrors(string arguments)
{
try
{
RunCommand(arguments);
}
catch (ApplicationException)
{
// We are deliberately ignoring errors; RunCommand will have already printed them
}
}

void RunCommand(string arguments)
{
foreach (var line in GetCommandOutput(arguments, true))
Expand Down

0 comments on commit c2b4c10

Please sign in to comment.