Skip to content

Commit c2b4c10

Browse files
committed
fix: Do not error out if remote missing
1 parent 79c68e1 commit c2b4c10

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Git/Project.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void Init(string repository)
2121
if (!Directory.Exists(GitPath)) Directory.CreateDirectory(GitPath);
2222
if (!File.Exists(Path.Join(GitPath, ".git", "config"))) RunCommand($"init");
2323

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

@@ -137,6 +137,18 @@ public void SetBranchRef(string branch, string reference)
137137
RunCommand($"branch -f {branch} {reference}");
138138
}
139139

140+
void RunCommandIgnoreErrors(string arguments)
141+
{
142+
try
143+
{
144+
RunCommand(arguments);
145+
}
146+
catch (ApplicationException)
147+
{
148+
// We are deliberately ignoring errors; RunCommand will have already printed them
149+
}
150+
}
151+
140152
void RunCommand(string arguments)
141153
{
142154
foreach (var line in GetCommandOutput(arguments, true))

0 commit comments

Comments
 (0)