Skip to content

Commit 24fca5e

Browse files
committed
fix: apply code formatting standards across codebase
Applied dotnet format to fix: - Whitespace and indentation inconsistencies - Missing final newlines in multiple files - Code alignment and spacing issues This ensures consistent code style throughout the project for better maintainability and readability.
1 parent 2264898 commit 24fca5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+511
-498
lines changed

src/Commands/Command.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ protected ProcessStartInfo CreateGitStartInfo(bool redirect)
176176

177177
// Get self executable file for SSH askpass
178178
var selfExecFile = Process.GetCurrentProcess().MainModule!.FileName;
179-
179+
180180
// Check if this is a public repository operation (but NOT push)
181181
var isPush = Args != null && Args.Contains("push ");
182-
var isPublicOperation = !isPush && (SkipCredentials || (Args != null &&
183-
(Args.Contains("github.com") || Args.Contains("gitlab.com") ||
182+
var isPublicOperation = !isPush && (SkipCredentials || (Args != null &&
183+
(Args.Contains("github.com") || Args.Contains("gitlab.com") ||
184184
Args.Contains("bitbucket.org") || Args.Contains("gitee.com"))));
185-
185+
186186
if (!isPublicOperation)
187187
{
188188
// Only set up SSH askpass for non-public repos
@@ -217,35 +217,35 @@ protected ProcessStartInfo CreateGitStartInfo(bool redirect)
217217

218218
var builder = new StringBuilder();
219219
builder.Append("--no-pager -c core.quotepath=off");
220-
220+
221221
// Check if we're working with a public repository (no credentials needed)
222222
var isPublicRepo = false;
223223
var needsCredentials = true;
224-
224+
225225
// Check for operations that typically don't need credentials on public repos
226226
if (Args != null)
227227
{
228228
// IMPORTANT: Push operations ALWAYS need credentials, even for public repos
229229
var isPushOperation = Args.Contains("push ");
230-
230+
231231
if (!isPushOperation)
232232
{
233233
// Check if this is a read-only operation on GitHub/GitLab
234-
var isReadOperation = Args.Contains("fetch") || Args.Contains("pull") ||
234+
var isReadOperation = Args.Contains("fetch") || Args.Contains("pull") ||
235235
Args.Contains("ls-remote") || Args.Contains("clone") ||
236236
Args.Contains("remote -v") || Args.Contains("remote get-url");
237-
237+
238238
// Check if URL contains public Git hosts
239-
var hasPublicHost = Args.Contains("github.com") || Args.Contains("gitlab.com") ||
239+
var hasPublicHost = Args.Contains("github.com") || Args.Contains("gitlab.com") ||
240240
Args.Contains("bitbucket.org") || Args.Contains("gitee.com");
241-
241+
242242
// If it's a read operation on a public host, disable credentials
243243
if (isReadOperation && hasPublicHost)
244244
{
245245
isPublicRepo = true;
246246
needsCredentials = false;
247247
}
248-
248+
249249
// Also check for HTTPS URLs which are typically public (but NOT for push)
250250
if (Args.Contains("https://github.com") || Args.Contains("https://gitlab.com"))
251251
{
@@ -254,7 +254,7 @@ protected ProcessStartInfo CreateGitStartInfo(bool redirect)
254254
}
255255
}
256256
}
257-
257+
258258
// ALWAYS explicitly set credential helper to avoid system defaults
259259
if (SkipCredentials || !needsCredentials || isPublicRepo)
260260
{
@@ -287,7 +287,7 @@ protected ProcessStartInfo CreateGitStartInfo(bool redirect)
287287
builder.Append($" -c credential.helper={Native.OS.CredentialHelper}");
288288
}
289289
}
290-
290+
291291
builder.Append(' ');
292292

293293
switch (Editor)

src/Commands/CommandWithRetry.cs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public class CommandWithRetry : Command
1212
private const int MAX_RETRIES = 5;
1313
private const int INITIAL_DELAY_MS = 100;
1414
private const int MAX_DELAY_MS = 5000;
15-
15+
1616
private readonly Command _innerCommand;
17-
17+
1818
public CommandWithRetry(Command command)
1919
{
2020
_innerCommand = command;
@@ -28,15 +28,15 @@ public CommandWithRetry(Command command)
2828
this.RaiseError = command.RaiseError;
2929
this.Log = command.Log;
3030
}
31-
31+
3232
/// <summary>
3333
/// Executes the command with retry logic for lock file conflicts
3434
/// </summary>
3535
public new async Task<bool> ExecAsync()
3636
{
3737
int retryCount = 0;
3838
int delayMs = INITIAL_DELAY_MS;
39-
39+
4040
while (retryCount < MAX_RETRIES)
4141
{
4242
// Check for lock files before attempting operation
@@ -47,24 +47,24 @@ public CommandWithRetry(Command command)
4747
retryCount++;
4848
continue;
4949
}
50-
50+
5151
try
5252
{
5353
// Store original RaiseError setting
5454
var originalRaiseError = this.RaiseError;
55-
55+
5656
// Suppress error for retry attempts
5757
if (retryCount > 0)
5858
this.RaiseError = false;
59-
59+
6060
var result = await base.ExecAsync();
61-
61+
6262
// Restore original setting
6363
this.RaiseError = originalRaiseError;
64-
64+
6565
if (result)
6666
return true;
67-
67+
6868
// Check if failure was due to lock file
6969
if (IsLockFileError())
7070
{
@@ -73,7 +73,7 @@ public CommandWithRetry(Command command)
7373
retryCount++;
7474
continue;
7575
}
76-
76+
7777
// If not a lock file error, return the failure
7878
return false;
7979
}
@@ -85,9 +85,9 @@ public CommandWithRetry(Command command)
8585
{
8686
if (retryCount >= MAX_RETRIES - 1)
8787
throw; // Rethrow on final attempt
88-
88+
8989
// Check if exception is lock-related
90-
if (ex.Message.Contains("index.lock") ||
90+
if (ex.Message.Contains("index.lock") ||
9191
ex.Message.Contains("Another git process") ||
9292
ex.Message.Contains("Unable to create") ||
9393
ex.Message.Contains("locked"))
@@ -97,24 +97,24 @@ public CommandWithRetry(Command command)
9797
retryCount++;
9898
continue;
9999
}
100-
100+
101101
throw; // Rethrow non-lock exceptions
102102
}
103103
}
104-
104+
105105
// Final attempt with error reporting enabled
106106
this.RaiseError = true;
107107
return await base.ExecAsync();
108108
}
109-
109+
110110
/// <summary>
111111
/// Executes the command with retry logic and returns the result
112112
/// </summary>
113113
public async Task<Command.Result> ReadToEndWithRetryAsync()
114114
{
115115
int retryCount = 0;
116116
int delayMs = INITIAL_DELAY_MS;
117-
117+
118118
while (retryCount < MAX_RETRIES)
119119
{
120120
// Check for lock files before attempting operation
@@ -125,14 +125,14 @@ public CommandWithRetry(Command command)
125125
retryCount++;
126126
continue;
127127
}
128-
128+
129129
try
130130
{
131131
var result = await base.ReadToEndAsync();
132-
132+
133133
if (result.IsSuccess)
134134
return result;
135-
135+
136136
// Check if failure was due to lock file
137137
if (IsLockFileError(result.StdErr))
138138
{
@@ -141,16 +141,16 @@ public CommandWithRetry(Command command)
141141
retryCount++;
142142
continue;
143143
}
144-
144+
145145
return result;
146146
}
147147
catch (Exception ex)
148148
{
149149
if (retryCount >= MAX_RETRIES - 1)
150150
return Command.Result.Failed(ex.Message);
151-
151+
152152
// Check if exception is lock-related
153-
if (ex.Message.Contains("index.lock") ||
153+
if (ex.Message.Contains("index.lock") ||
154154
ex.Message.Contains("Another git process") ||
155155
ex.Message.Contains("Unable to create") ||
156156
ex.Message.Contains("locked"))
@@ -160,45 +160,45 @@ public CommandWithRetry(Command command)
160160
retryCount++;
161161
continue;
162162
}
163-
163+
164164
return Command.Result.Failed(ex.Message);
165165
}
166166
}
167-
167+
168168
// Final attempt
169169
return await base.ReadToEndAsync();
170170
}
171-
171+
172172
/// <summary>
173173
/// Checks if common Git lock files exist
174174
/// </summary>
175175
private bool HasLockFiles()
176176
{
177177
if (string.IsNullOrEmpty(WorkingDirectory))
178178
return false;
179-
179+
180180
var gitDir = Path.Combine(WorkingDirectory, ".git");
181181
if (!Directory.Exists(gitDir))
182182
return false;
183-
183+
184184
// Check for common lock files
185-
string[] lockFiles =
185+
string[] lockFiles =
186186
{
187187
Path.Combine(gitDir, "index.lock"),
188188
Path.Combine(gitDir, "HEAD.lock"),
189189
Path.Combine(gitDir, "config.lock"),
190190
Path.Combine(gitDir, "refs", "heads", "*.lock"),
191191
Path.Combine(gitDir, "refs", "remotes", "*.lock")
192192
};
193-
193+
194194
foreach (var lockFile in lockFiles)
195195
{
196196
if (lockFile.Contains('*'))
197197
{
198198
// Handle wildcard patterns
199199
var dir = Path.GetDirectoryName(lockFile);
200200
var pattern = Path.GetFileName(lockFile);
201-
201+
202202
if (Directory.Exists(dir))
203203
{
204204
var files = Directory.GetFiles(dir, pattern);
@@ -229,10 +229,10 @@ private bool HasLockFiles()
229229
}
230230
}
231231
}
232-
232+
233233
return false;
234234
}
235-
235+
236236
/// <summary>
237237
/// Checks if the command failed due to a lock file
238238
/// </summary>
@@ -242,16 +242,16 @@ private bool IsLockFileError()
242242
// For now, we'll rely on the external error checking
243243
return false;
244244
}
245-
245+
246246
/// <summary>
247247
/// Checks if error message indicates a lock file issue
248248
/// </summary>
249249
private bool IsLockFileError(string errorMessage)
250250
{
251251
if (string.IsNullOrEmpty(errorMessage))
252252
return false;
253-
254-
string[] lockIndicators =
253+
254+
string[] lockIndicators =
255255
{
256256
"index.lock",
257257
"Another git process",
@@ -262,14 +262,14 @@ private bool IsLockFileError(string errorMessage)
262262
"already exists",
263263
"cannot lock ref"
264264
};
265-
265+
266266
foreach (var indicator in lockIndicators)
267267
{
268268
if (errorMessage.Contains(indicator, StringComparison.OrdinalIgnoreCase))
269269
return true;
270270
}
271-
271+
272272
return false;
273273
}
274274
}
275-
}
275+
}

src/Commands/CountBranches.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ public CountBranches(string repo)
9999
return new BranchCount();
100100
}
101101
}
102-
}
102+
}

src/Commands/Fetch.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public async Task<bool> RunAsync()
4343
if (!string.IsNullOrEmpty(remoteUrl) && remoteUrl.StartsWith("https://"))
4444
{
4545
// For public HTTPS repos, we don't need SSH keys or credentials
46-
if (remoteUrl.Contains("github.com") || remoteUrl.Contains("gitlab.com") ||
46+
if (remoteUrl.Contains("github.com") || remoteUrl.Contains("gitlab.com") ||
4747
remoteUrl.Contains("bitbucket.org") || remoteUrl.Contains("gitee.com"))
4848
{
4949
// Skip SSH key and credentials for public repos
@@ -64,7 +64,7 @@ public async Task<bool> RunAsync()
6464
{
6565
SSHKey = await new Config(WorkingDirectory).GetAsync(_remoteKey).ConfigureAwait(false);
6666
}
67-
67+
6868
return await ExecAsync().ConfigureAwait(false);
6969
}
7070

0 commit comments

Comments
 (0)