|
|
@ -84,7 +84,7 @@ namespace CppSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
while (stringBuilder.Length > 0 && stringBuilder[0] == '_') |
|
|
|
while (stringBuilder.Length > 0 && stringBuilder[0] == '_') |
|
|
|
stringBuilder.Remove(0, 1); |
|
|
|
stringBuilder.Remove(0, 1); |
|
|
|
while (stringBuilder.Length > 0 && stringBuilder[stringBuilder.Length - 1] == '_') |
|
|
|
while (stringBuilder.Length > 0 && stringBuilder[^1] == '_') |
|
|
|
stringBuilder.Remove(stringBuilder.Length - 1, 1); |
|
|
|
stringBuilder.Remove(stringBuilder.Length - 1, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -136,47 +136,54 @@ namespace CppSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
public static NewLineType? GetNewLineTypeFromGitConfig(string outputDir) |
|
|
|
public static NewLineType? GetNewLineTypeFromGitConfig(string outputDir) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!bool.TryParse( |
|
|
|
try |
|
|
|
ProcessHelper.RunFrom(outputDir, |
|
|
|
|
|
|
|
"git", "rev-parse --is-inside-work-tree", |
|
|
|
|
|
|
|
out _, out _ |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
out bool isInsideWorkTree)) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return null; |
|
|
|
if (!bool.TryParse( |
|
|
|
} |
|
|
|
ProcessHelper.RunFrom(outputDir, |
|
|
|
|
|
|
|
"git", "rev-parse --is-inside-work-tree", |
|
|
|
|
|
|
|
out _, out _ |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
out bool isInsideWorkTree)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!isInsideWorkTree) |
|
|
|
if (!isInsideWorkTree) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
// Check git config core.eol setting
|
|
|
|
// Check git config core.eol setting
|
|
|
|
var eolConfig = ProcessHelper.RunFrom(outputDir, |
|
|
|
var eolConfig = ProcessHelper.RunFrom(outputDir, |
|
|
|
"git", "config --get core.eol", |
|
|
|
"git", "config --get core.eol", |
|
|
|
out _, out _) |
|
|
|
out _, out _) |
|
|
|
.Trim().ToLowerInvariant(); |
|
|
|
.Trim().ToLowerInvariant(); |
|
|
|
|
|
|
|
|
|
|
|
switch (eolConfig) |
|
|
|
switch (eolConfig) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case "lf": |
|
|
|
case "lf": |
|
|
|
return NewLineType.LF; |
|
|
|
return NewLineType.LF; |
|
|
|
case "crlf": |
|
|
|
case "crlf": |
|
|
|
return NewLineType.CRLF; |
|
|
|
return NewLineType.CRLF; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Otherwise check git config core.autocrlf setting
|
|
|
|
// Otherwise check git config core.autocrlf setting
|
|
|
|
var autoCrLf = ProcessHelper.RunFrom(outputDir, |
|
|
|
var autoCrLf = ProcessHelper.RunFrom(outputDir, |
|
|
|
"git", "config --get core.autocrlf", |
|
|
|
"git", "config --get core.autocrlf", |
|
|
|
out _, out _) |
|
|
|
out _, out _) |
|
|
|
.Trim().ToLowerInvariant(); |
|
|
|
.Trim().ToLowerInvariant(); |
|
|
|
|
|
|
|
|
|
|
|
return autoCrLf switch |
|
|
|
return autoCrLf switch |
|
|
|
{ |
|
|
|
{ |
|
|
|
"input" => NewLineType.LF, |
|
|
|
"input" => NewLineType.LF, |
|
|
|
"true" => NewLineType.CRLF, |
|
|
|
"true" => NewLineType.CRLF, |
|
|
|
"false" => NewLineType.Host, |
|
|
|
"false" => NewLineType.Host, |
|
|
|
|
|
|
|
|
|
|
|
_ => null |
|
|
|
_ => null |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|