FormatGitSSHCommand() public static méthode

public static FormatGitSSHCommand ( SSHAuthenticationInfo auth_info ) : string
auth_info SSHAuthenticationInfo
Résultat string
Exemple #1
0
        void InstallGitLFS()
        {
            var git_config_required = new GitCommand(TargetFolder, "config filter.lfs.required true");

            string GIT_SSH_COMMAND = GitCommand.FormatGitSSHCommand(auth_info);
            string smudge_command;
            string clean_command;

            if (InstallationInfo.OperatingSystem == OS.macOS || InstallationInfo.OperatingSystem == OS.Windows)
            {
                smudge_command = "env GIT_SSH_COMMAND='" + GIT_SSH_COMMAND + "' " +
                                 Path.Combine(Configuration.DefaultConfiguration.BinPath, "git-lfs").Replace("\\", "/") + " smudge %f";

                clean_command = Path.Combine(Configuration.DefaultConfiguration.BinPath, "git-lfs").Replace("\\", "/") + " clean %f";
            }
            else
            {
                smudge_command = "env GIT_SSH_COMMAND='" + GIT_SSH_COMMAND + "' git-lfs smudge %f";
                clean_command  = "git-lfs clean %f";
            }

            var git_config_smudge = new GitCommand(TargetFolder,
                                                   string.Format("config filter.lfs.smudge \"{0}\"", smudge_command));

            var git_config_clean = new GitCommand(TargetFolder,
                                                  string.Format("config filter.lfs.clean '{0}'", clean_command));

            git_config_required.StartAndWaitForExit();
            git_config_clean.StartAndWaitForExit();
            git_config_smudge.StartAndWaitForExit();
        }
Exemple #2
0
        // The pre-push hook may have been changed by Git LFS, overwrite it to use our own configuration
        void PrepareGitLFS()
        {
            string pre_push_hook_path = Path.Combine(LocalPath, ".git", "hooks", "pre-push");
            string pre_push_hook_content;

            if (InstallationInfo.OperatingSystem == OS.macOS || InstallationInfo.OperatingSystem == OS.Windows)
            {
                pre_push_hook_content =
                    "#!/bin/sh" + Environment.NewLine +
                    "env GIT_SSH_COMMAND='" + GitCommand.FormatGitSSHCommand(auth_info) + "' " +
                    Path.Combine(Configuration.DefaultConfiguration.BinPath, "git-lfs").Replace("\\", "/") + " pre-push \"$@\"";
            }
            else
            {
                pre_push_hook_content =
                    "#!/bin/sh" + Environment.NewLine +
                    "env GIT_SSH_COMMAND='" + GitCommand.FormatGitSSHCommand(auth_info) + "' " +
                    "git-lfs pre-push \"$@\"";
            }

            if (InstallationInfo.OperatingSystem != OS.Windows)
            {
                // TODO: Use proper API
                var chmod = new Command("chmod", "700 " + pre_push_hook_path);
                chmod.StartAndWaitForExit();
            }

            Directory.CreateDirectory(Path.GetDirectoryName(pre_push_hook_path));
            File.WriteAllText(pre_push_hook_path, pre_push_hook_content);
        }
Exemple #3
0
        public GitRepository(string path, Configuration config, SSHAuthenticationInfo auth_info) : base(path, config)
        {
            this.auth_info = auth_info;

            var git_config = new GitCommand(LocalPath, "config core.ignorecase false");

            git_config.StartAndWaitForExit();

            git_config = new GitCommand(LocalPath, "config remote.origin.url \"" + RemoteUrl + "\"");
            git_config.StartAndWaitForExit();

            git_config = new GitCommand(LocalPath, "config core.sshCommand " + GitCommand.FormatGitSSHCommand(auth_info));
            git_config.StartAndWaitForExit();
        }
Exemple #4
0
        public GitRepository(string path, Configuration config, SSHAuthenticationInfo auth_info) : base(path, config)
        {
            this.auth_info = auth_info;

            var git_config = new GitCommand(LocalPath, "config core.ignorecase false");

            git_config.StartAndWaitForExit();

            git_config = new GitCommand(LocalPath, "config remote.origin.url \"" + RemoteUrl + "\"");
            git_config.StartAndWaitForExit();

            git_config = new GitCommand(LocalPath, "config core.sshCommand " + GitCommand.FormatGitSSHCommand(auth_info));
            git_config.StartAndWaitForExit();

            if (InstallationInfo.OperatingSystem != OS.Windows)
            {
                string pre_push_hook_path = Path.Combine(LocalPath, ".git", "hooks", "pre-push");

                // TODO: Use proper API
                var chmod = new Command("chmod", "700 " + pre_push_hook_path);
                chmod.StartAndWaitForExit();
            }
        }
        public override bool SyncUp()
        {
            if (!Add())
            {
                Error = ErrorStatus.UnreadableFiles;
                return(false);
            }

            string message = base.status_message.Replace("\"", "\\\"");

            if (string.IsNullOrEmpty(message))
            {
                message = FormatCommitMessage();
            }

            if (message != null)
            {
                Commit(message);
            }

            string pre_push_hook_path = Path.Combine(LocalPath, ".git", "hooks", "pre-push");
            string pre_push_hook_content;

            // The pre-push hook may have been changed by Git LFS, overwrite it to use our own configuration
            if (InstallationInfo.OperatingSystem == OS.Mac)
            {
                pre_push_hook_content =
                    "#!/bin/sh" + Environment.NewLine +
                    "env GIT_SSH_COMMAND='" + GitCommand.FormatGitSSHCommand(auth_info) + "' " +
                    Path.Combine(Configuration.DefaultConfiguration.BinPath, "git-lfs") + " pre-push \"$@\"";
            }
            else
            {
                pre_push_hook_content =
                    "#!/bin/sh" + Environment.NewLine +
                    "env GIT_SSH_COMMAND='" + GitCommand.FormatGitSSHCommand(auth_info) + "' " +
                    "git-lfs pre-push \"$@\"";
            }

            Directory.CreateDirectory(Path.GetDirectoryName(pre_push_hook_path));
            File.WriteAllText(pre_push_hook_path, pre_push_hook_content);

            var git_push = new GitCommand(LocalPath, string.Format("push --all --progress origin", RemoteUrl), auth_info);

            git_push.StartInfo.RedirectStandardError = true;
            git_push.Start();

            if (!ReadStream(git_push))
            {
                return(false);
            }

            git_push.WaitForExit();

            UpdateSizes();

            if (git_push.ExitCode == 0)
            {
                return(true);
            }

            Error = ErrorStatus.HostUnreachable;
            return(false);
        }