diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/SDL.cs b/Source/Tools/Flax.Build/Deps/Dependencies/SDL.cs index d2e393a8e..c1b06d7d7 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/SDL.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/SDL.cs @@ -89,6 +89,7 @@ namespace Flax.Deps.Dependencies }; CloneGitRepoFast(root, "https://github.com/libsdl-org/SDL"); + GitFetch(root); GitResetToCommit(root, "535d80badefc83c5c527ec5748f2a20d6a9310fe"); // 3.2.0 foreach (var platform in options.Platforms) diff --git a/Source/Tools/Flax.Build/Deps/Dependency.cs b/Source/Tools/Flax.Build/Deps/Dependency.cs index a5ead049f..faca35299 100644 --- a/Source/Tools/Flax.Build/Deps/Dependency.cs +++ b/Source/Tools/Flax.Build/Deps/Dependency.cs @@ -131,6 +131,18 @@ namespace Flax.Deps Utilities.DirectoryCopy(src, dst); } + /// + /// Checks if git repository exists at given path. + /// + /// The path. + public static bool GitRepositoryExists(string path) + { + Console.WriteLine(path); + string dotGitPath = Path.Combine(path, ".git"); + return Directory.Exists(dotGitPath) || + File.Exists(dotGitPath); // Worktree repository + } + /// /// Clones the git repository from the remote url (full repository). /// @@ -141,7 +153,7 @@ namespace Flax.Deps /// True if initialize submodules of the repository (recursive). public static void CloneGitRepo(string path, string url, string commit = null, string args = null, bool submodules = false) { - if (!Directory.Exists(Path.Combine(path, ".git"))) + if (!GitRepositoryExists(path)) { string cmdLine = string.Format("clone \"{0}\" \"{1}\"", url, path); if (args != null) @@ -166,7 +178,7 @@ namespace Flax.Deps /// True if initialize submodules of the repository (recursive). public static void CloneGitRepoFast(string path, string url, string args = null, bool submodules = false) { - if (!Directory.Exists(Path.Combine(path, ".git"))) + if (!GitRepositoryExists(path)) { string cmdLine = string.Format("clone \"{0}\" \"{1}\" --depth 1", url, path); if (args != null) @@ -181,26 +193,15 @@ namespace Flax.Deps } /// - /// Clones the git repository from the remote url. + /// Fetches the git repository from remote url. /// - /// The local path for close. - /// The remote url. - /// The time after history is included in the local repository. - /// The custom arguments to add to the clone command. - /// True if initialize submodules of the repository (recursive). - public static void CloneGitRepoFastSince(string path, string url, DateTime time, string args = null, bool submodules = false) + /// The git repository path + /// The remote url + public static void GitFetch(string path) { - if (!Directory.Exists(Path.Combine(path, ".git"))) + if (GitRepositoryExists(path)) { - string cmdLine = string.Format("clone \"{0}\" \"{1}\" --shallow-since={2}", url, path, time.ToString("s")); - if (args != null) - cmdLine += " " + args; - if (submodules) - cmdLine += " --recurse-submodules"; - - Utilities.Run("git", cmdLine, null, path, Utilities.RunOptions.DefaultTool); - if (submodules) - Utilities.Run("git", "submodule update --init --recursive", null, path, Utilities.RunOptions.DefaultTool); + Utilities.Run("git", $"fetch \"{path}\"", null, path, Utilities.RunOptions.DefaultTool); } } @@ -215,7 +216,7 @@ namespace Flax.Deps /// True if initialize submodules of the repository (recursive). public static void CloneGitRepoSingleBranch(string path, string url, string branch, string commit = null, string args = null, bool submodules = false) { - if (!Directory.Exists(Path.Combine(path, ".git"))) + if (!GitRepositoryExists(path)) { string cmdLine = string.Format("clone --single-branch --branch {2} \"{0}\" \"{1}\"", url, path, branch); if (commit == null)