Skip to content

Commit

Permalink
Fix app path name of Windows dropping file extension (#1181)
Browse files Browse the repository at this point in the history
During some refactoring we accidentially introduced an error in the 'app
path' on the CommandContext`; rather than trimming the file extension
off (for detection of the old executable name on Windows) on a local
copy, we are now updating the app wide copy!

Only mutate a local copy.
  • Loading branch information
mjcheetham authored Apr 4, 2023
2 parents fc4fbae + 35f16af commit dc1edca
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/shared/Git-Credential-Manager/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,17 @@ public static void Main(string[] args)
//
// On UNIX systems we do the same check, except instead of a copy we use a symlink.
//
if (!string.IsNullOrWhiteSpace(context.ApplicationPath))
string appPath = context.ApplicationPath;
if (!string.IsNullOrWhiteSpace(appPath))
{
// Trim any (.exe) file extension if we're on Windows
// Note that in some circumstances (like being called by Git when config is set
// to just `helper = manager-core`) we don't always have ".exe" at the end.
if (PlatformUtils.IsWindows() && context.ApplicationPath.EndsWith(".exe",
StringComparison.OrdinalIgnoreCase))
if (PlatformUtils.IsWindows() && appPath.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
{
context.ApplicationPath = context.ApplicationPath
.Substring(0, context.ApplicationPath.Length - 4);
appPath = appPath.Substring(0, appPath.Length - 4);
}
if (context.ApplicationPath.EndsWith("git-credential-manager-core",
StringComparison.OrdinalIgnoreCase))
if (appPath.EndsWith("git-credential-manager-core", StringComparison.OrdinalIgnoreCase))
{
context.Streams.Error.WriteLine(
"warning: git-credential-manager-core was renamed to git-credential-manager");
Expand Down

0 comments on commit dc1edca

Please sign in to comment.