Ejemplo n.º 1
0
        public override string GetTemplateHooksDirectory()
        {
            string gitBinPath = GitInstallation.GetInstalledGitBinPath();

            string tail = Path.Combine("cmd", "git.exe");

            if (gitBinPath.EndsWith(tail))
            {
                string gitBasePath = gitBinPath.Substring(0, gitBinPath.Length - tail.Length);
                return(Path.Combine(gitBasePath, "mingw64", ScalarConstants.InstalledGit.HookTemplateDir));
            }

            return(null);
        }
Ejemplo n.º 2
0
        public override string GetTemplateHooksDirectory()
        {
            string gitExecPath = GitInstallation.GetInstalledGitBinPath();

            // Resolve symlinks
            string resolvedExecPath = NativeMethods.ResolveSymlink(gitExecPath);

            // Get the containing bin directory
            string gitBinDir = Path.GetDirectoryName(resolvedExecPath);

            // Compute the base installation path (../)
            string installBaseDir = Path.GetDirectoryName(gitBinDir);

            installBaseDir = Path.GetFullPath(installBaseDir);

            return(Path.Combine(installBaseDir, ScalarConstants.InstalledGit.HookTemplateDir));
        }
 public static bool FindGitInstallation(string path, KnownGitDistribution distro, out GitInstallation installation)
 {
     installation = new GitInstallation(path, distro);
     return GitInstallation.IsValid(installation);
 }
        /// <summary>
        /// Gets the path to the Git system configuration file.
        /// </summary>
        /// <param name="path">Path to the Git system configuration.</param>
        /// <returns><see langword="True"/> if succeeds; <see langword="false"/> otherwise.</returns>
        public static bool GitSystemConfig(GitInstallation? installation, out string path)
        {
            if (installation.HasValue && File.Exists(installation.Value.Config))
            {
                path = installation.Value.Path;
            }
            // find Git on the local disk - the system config is stored relative to it
            else
            {
                List<GitInstallation> installations;

                if (FindGitInstallations(out installations)
                    && File.Exists(installations[0].Config))
                {
                    path = installations[0].Config;
                }
            }

            path = null;
            return false;
        }