git repo: Make sure Git LFS is always set up
This commit is contained in:
parent
9c1e6d8f7a
commit
6379e31b3c
|
@ -440,14 +440,6 @@ namespace Sparkles.Git {
|
||||||
git_config_required.StartAndWaitForExit ();
|
git_config_required.StartAndWaitForExit ();
|
||||||
git_config_clean.StartAndWaitForExit ();
|
git_config_clean.StartAndWaitForExit ();
|
||||||
git_config_smudge.StartAndWaitForExit ();
|
git_config_smudge.StartAndWaitForExit ();
|
||||||
|
|
||||||
if (InstallationInfo.OperatingSystem != OS.Windows) {
|
|
||||||
string pre_push_hook_path = Path.Combine (TargetFolder, ".git", "hooks", "pre-push");
|
|
||||||
|
|
||||||
// TODO: Use proper API
|
|
||||||
var chmod = new Command ("chmod", "700 " + pre_push_hook_path);
|
|
||||||
chmod.StartAndWaitForExit ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,13 +82,7 @@ namespace Sparkles.Git {
|
||||||
git_config = new GitCommand (LocalPath, "config core.sshCommand " + GitCommand.FormatGitSSHCommand (auth_info));
|
git_config = new GitCommand (LocalPath, "config core.sshCommand " + GitCommand.FormatGitSSHCommand (auth_info));
|
||||||
git_config.StartAndWaitForExit();
|
git_config.StartAndWaitForExit();
|
||||||
|
|
||||||
if (InstallationInfo.OperatingSystem != OS.Windows) {
|
PrepareGitLFS ();
|
||||||
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 ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -221,25 +215,7 @@ namespace Sparkles.Git {
|
||||||
if (message != null)
|
if (message != null)
|
||||||
Commit (message);
|
Commit (message);
|
||||||
|
|
||||||
string pre_push_hook_path = Path.Combine (LocalPath, ".git", "hooks", "pre-push");
|
PrepareGitLFS ();
|
||||||
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.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 \"$@\"";
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
var git_push = new GitCommand (LocalPath, string.Format ("push --all --progress origin", RemoteUrl), auth_info);
|
||||||
git_push.StartInfo.RedirectStandardError = true;
|
git_push.StartInfo.RedirectStandardError = true;
|
||||||
|
@ -909,6 +885,36 @@ namespace Sparkles.Git {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Git doesn't track empty directories, so this method
|
// Git doesn't track empty directories, so this method
|
||||||
// fills them all with a hidden empty file.
|
// fills them all with a hidden empty file.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue