Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 408e626

Browse files
Merge pull request #751 from github-for-unity/fixes/git-lfs-mac
Fix installing lfs on a mac
2 parents ecc425f + 1ed82fd commit 408e626

File tree

14 files changed

+63
-39
lines changed

14 files changed

+63
-39
lines changed

generate-package.sh

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ if [ $# -ge 7 ]; then
3030
MSG="$7"
3131
fi
3232

33-
EXEC="mono"
33+
EXEC="mono "
3434
if [ -e "/c/" ]; then
3535
EXEC=""
3636
fi
3737

38-
if [ ! -e "$DIR/build/CommandLine/CommandLine.exe" ]; then
38+
if [ ! -e "build/CommandLine/CommandLine.exe" ]; then
3939
>&2 xbuild /target:CommandLine "$DIR/GitHub.Unity.sln" /verbosity:minimal
4040
fi
4141

42-
"$EXEC""$DIR/build/CommandLine/CommandLine.exe" --gen-package --version "$3" --path "$4" --url "$URL" --rn "$RN" --msg "$MSG"
42+
$EXEC build/CommandLine/CommandLine.exe --gen-package --version "$3" --path "$4" --url "$URL" --rn "$RN" --msg "$MSG"

run-test-webserver.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ if [ ! -e build/CommandLine/CommandLine.exe ]; then
1313
>&2 xbuild /target:CommandLine GitHub.Unity.sln /verbosity:minimal
1414
fi
1515

16-
"$EXEC"build/CommandLine/CommandLine.exe --web --port $PORT
16+
$EXEC build/CommandLine/CommandLine.exe --web --port $PORT

src/GitHub.Api/IO/NiceIO.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,9 @@ public override int GetHashCode()
476476
hash = hash * 23 + _isInitialized.GetHashCode();
477477
hash = hash * 23 + _isRelative.GetHashCode();
478478
foreach (var element in _elements)
479-
hash = hash * 23 + (IsLinux ? element : element.ToUpperInvariant()).GetHashCode();
479+
hash = hash * 23 + (IsUnix ? element : element.ToUpperInvariant()).GetHashCode();
480480
if (_driveLetter != null)
481-
hash = hash * 23 + (IsLinux ? _driveLetter : _driveLetter.ToUpperInvariant()).GetHashCode();
481+
hash = hash * 23 + (IsUnix ? _driveLetter : _driveLetter.ToUpperInvariant()).GetHashCode();
482482
return hash;
483483
}
484484
}
@@ -1087,14 +1087,14 @@ public static IFileSystem FileSystem
10871087
}
10881088
}
10891089

1090-
private static bool? _isLinux;
1091-
internal static bool IsLinux
1090+
private static bool? _isUnix;
1091+
internal static bool IsUnix
10921092
{
10931093
get
10941094
{
1095-
if (!_isLinux.HasValue)
1096-
_isLinux = FileSystem.DirectoryExists("/proc");
1097-
return _isLinux.Value;
1095+
if (!_isUnix.HasValue)
1096+
_isUnix = Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix;
1097+
return _isUnix.Value;
10981098
}
10991099
}
11001100

@@ -1103,10 +1103,10 @@ private static StringComparison PathStringComparison
11031103
{
11041104
get
11051105
{
1106-
// this is lazily evaluated because IsLinux uses the FileSystem object and that can be set
1106+
// this is lazily evaluated because IsUnix uses the FileSystem object and that can be set
11071107
// after static constructors happen here
11081108
if (!_pathStringComparison.HasValue)
1109-
_pathStringComparison = IsLinux ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
1109+
_pathStringComparison = IsUnix ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
11101110
return _pathStringComparison.Value;
11111111
}
11121112
}
@@ -1165,7 +1165,7 @@ public static NPath Resolve(this NPath path)
11651165
{
11661166
// Add a reference to Mono.Posix with an .rsp file in the Assets folder with the line "-r:Mono.Posix.dll" for this to work
11671167
#if ENABLE_MONO
1168-
if (!path.IsInitialized || !NPath.IsLinux /* nothing to resolve on windows */ || path.IsRelative || !path.FileExists())
1168+
if (!path.IsInitialized || !NPath.IsUnix /* nothing to resolve on windows */ || path.IsRelative || !path.FileExists())
11691169
return path;
11701170
return new NPath(Mono.Unix.UnixPath.GetCompleteRealPath(path.ToString()));
11711171
#else

src/GitHub.Api/Installer/ZipHelper.cs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,28 @@ public bool Extract(string archive, string outFolder, CancellationToken cancella
6767
{
6868
Directory.CreateDirectory(directoryName);
6969
}
70-
//#if !WINDOWS
71-
// if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
72-
// {
73-
// if (zipEntry.ExternalFileAttributes > 0)
74-
// {
75-
// int fd = Mono.Unix.Native.Syscall.open(fullZipToPath,
76-
// Mono.Unix.Native.OpenFlags.O_CREAT | Mono.Unix.Native.OpenFlags.O_TRUNC,
77-
// (Mono.Unix.Native.FilePermissions)zipEntry.ExternalFileAttributes);
78-
// Mono.Unix.Native.Syscall.close(fd);
79-
// }
80-
// }
81-
//#endif
70+
71+
try
72+
{
73+
if (NPath.IsUnix)
74+
{
75+
if (zipEntry.ExternalFileAttributes == -2115174400)
76+
{
77+
int fd = Mono.Unix.Native.Syscall.open(fullZipToPath,
78+
Mono.Unix.Native.OpenFlags.O_CREAT | Mono.Unix.Native.OpenFlags.O_TRUNC,
79+
Mono.Unix.Native.FilePermissions.S_IRWXU |
80+
Mono.Unix.Native.FilePermissions.S_IRGRP |
81+
Mono.Unix.Native.FilePermissions.S_IXGRP |
82+
Mono.Unix.Native.FilePermissions.S_IROTH |
83+
Mono.Unix.Native.FilePermissions.S_IXOTH);
84+
Mono.Unix.Native.Syscall.close(fd);
85+
}
86+
}
87+
}
88+
catch (Exception ex)
89+
{
90+
LogHelper.Error(ex, "Error setting file attributes in " + fullZipToPath);
91+
}
8292

8393
// Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size
8494
// of the file, but does not waste memory.

src/GitHub.Api/Platform/ProcessEnvironment.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public void Configure(ProcessStartInfo psi, NPath workingDirectory, bool dontSet
3838
string separator = Environment.IsWindows ? ";" : ":";
3939

4040
NPath libexecPath = NPath.Default;
41+
List<string> gitPathEntries = new List<string>();
4142
if (Environment.GitInstallPath.IsInitialized)
4243
{
4344
var gitPathRoot = Environment.GitExecutablePath.Resolve().Parent.Parent;
@@ -60,16 +61,16 @@ public void Configure(ProcessStartInfo psi, NPath workingDirectory, bool dontSet
6061

6162
if (Environment.IsWindows)
6263
{
63-
pathEntries.AddRange(new[] { gitPathRoot.Combine("cmd").ToString(), gitPathRoot.Combine("usr", "bin") });
64+
gitPathEntries.AddRange(new[] { gitPathRoot.Combine("cmd").ToString(), gitPathRoot.Combine("usr", "bin") });
6465
}
6566
else
6667
{
67-
pathEntries.Add(gitExecutableDir.ToString());
68+
gitPathEntries.Add(gitExecutableDir.ToString());
6869
}
6970

7071
if (libexecPath.IsInitialized)
71-
pathEntries.Add(libexecPath);
72-
pathEntries.Add(binPath);
72+
gitPathEntries.Add(libexecPath);
73+
gitPathEntries.Add(binPath);
7374

7475
// we can only set this env var if there is a libexec/git-core. git will bypass internally bundled tools if this env var
7576
// is set, which will break Apple's system git on certain tools (like osx-credentialmanager)
@@ -81,6 +82,8 @@ public void Configure(ProcessStartInfo psi, NPath workingDirectory, bool dontSet
8182
{
8283
pathEntries.Add(Environment.GitLfsInstallPath);
8384
}
85+
if (gitPathEntries.Count > 0)
86+
pathEntries.AddRange(gitPathEntries);
8487

8588
pathEntries.Add("END");
8689

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{"md5":"c78270c2c94a4adce4beeef3010c732e","url":"http://ghfvs-installer.github.com/unity/git/mac/git-lfs.zip","releaseNotes":null,"releaseNotesUrl":null,"message":null,"version":"2.4.0"}
1+
{"md5":"e2941215f99afa99f002e96c0ae70966","url":"http://ghfvs-installer.github.com/unity/git/mac/git-lfs.zip","releaseNotes":null,"releaseNotesUrl":null,"message":null,"version":"2.4.0"}
2+
WARNING: The runtime version supported by this application is unavailable.
3+
Using default runtime: v4.0.30319
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:d8d924dfef97d579305a485f30ad3866f775b295394be199eb487faca4357672
3-
size 2831355
2+
oid sha256:4e1ea7c1c6b78c05293039c634426760dfc36cedd6a8a8e92ab26809abcf829a
3+
size 2936128

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/GitPathView.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public override void OnGUI()
124124
if (EditorGUI.EndChangeCheck())
125125
{
126126
changingManually = true;
127+
errorMessage = "";
127128
}
128129
}
129130
GUILayout.EndHorizontal();
@@ -156,6 +157,7 @@ public override void OnGUI()
156157
resetToBundled = true;
157158
resetToSystem = false;
158159
changingManually = false;
160+
errorMessage = "";
159161
}
160162

161163
//Find button - for attempting to locate a new install
@@ -189,6 +191,7 @@ public override void OnGUI()
189191
resetToBundled = false;
190192
resetToSystem = true;
191193
changingManually = false;
194+
errorMessage = "";
192195
Redraw();
193196
})
194197
.Start();

src/tests/IntegrationTests/Installer/GitInstallerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ public void GitLfsIsInstalledIfMissingWithCustomGitPath()
253253
var procTask = new SimpleProcessTask(TaskManager.Token, "something")
254254
.Configure(ProcessManager);
255255
var pathList = procTask.Process.StartInfo.EnvironmentVariables["PATH"].ToNPathList(Environment).TakeWhile(x => x != "END");
256-
pathList.First().Should().Be(gitExec.Parent);
257-
pathList.Any(x => x == gitLfsExec.Parent).Should().BeTrue();
256+
pathList.First().Should().Be(gitLfsExec.Parent);
257+
pathList.Skip(1).First().Should().Be(gitExec.Parent);
258258
}
259259
}
260260
}

src/tests/TestWebServer/HttpServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private void Process(HttpListenerContext context)
105105
var filename = context.Request.Url.AbsolutePath;
106106
Logger.Info($"{filename}");
107107
filename = filename.TrimStart('/');
108-
filename = filename.Replace('/', '\\');
108+
filename = filename.Replace('/', Path.DirectorySeparatorChar);
109109
filename = Path.Combine(rootDirectory, filename);
110110

111111
if (!File.Exists(filename))

0 commit comments

Comments
 (0)