2011-06-01 23:08:05 +00:00
|
|
|
// SparkleShare, a collaboration and sharing tool.
|
2011-05-16 20:19:58 +00:00
|
|
|
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
2015-01-13 22:20:50 +00:00
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
2013-10-11 15:13:46 +00:00
|
|
|
// License, or (at your option) any later version.
|
2011-05-16 20:19:58 +00:00
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
2013-10-11 15:13:46 +00:00
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.IO;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Threading;
|
2011-05-16 20:19:58 +00:00
|
|
|
|
2016-03-31 08:35:26 +00:00
|
|
|
namespace Sparkles.Git {
|
2011-05-16 20:19:58 +00:00
|
|
|
|
2016-03-30 23:36:31 +00:00
|
|
|
public class GitFetcher : SSHFetcher {
|
2011-05-16 20:19:58 +00:00
|
|
|
|
2016-04-04 09:27:20 +00:00
|
|
|
SSHAuthenticationInfo auth_info;
|
2016-04-05 07:55:11 +00:00
|
|
|
GitCommand git_clone;
|
2012-09-29 21:57:35 +00:00
|
|
|
|
2016-03-28 17:14:21 +00:00
|
|
|
Regex progress_regex = new Regex (@"([0-9]+)%", RegexOptions.Compiled);
|
|
|
|
Regex speed_regex = new Regex (@"([0-9\.]+) ([KM])iB/s", RegexOptions.Compiled);
|
2013-08-25 16:46:06 +00:00
|
|
|
|
2016-03-28 17:14:21 +00:00
|
|
|
string password_salt = "662282447f6bbb8c8e15fb32dd09e3e708c32bc8";
|
2013-08-25 16:46:06 +00:00
|
|
|
|
2016-03-28 17:14:21 +00:00
|
|
|
|
|
|
|
public override bool IsFetchedRepoEmpty {
|
2012-09-29 21:57:35 +00:00
|
|
|
get {
|
2016-04-05 07:55:11 +00:00
|
|
|
var git_rev_parse = new GitCommand (TargetFolder, "rev-parse HEAD");
|
|
|
|
git_rev_parse.StartAndWaitForExit ();
|
2012-09-29 21:57:35 +00:00
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
return (git_rev_parse.ExitCode != 0);
|
2012-09-29 21:57:35 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-26 20:47:46 +00:00
|
|
|
|
|
|
|
|
2016-04-04 09:27:20 +00:00
|
|
|
public GitFetcher (SparkleFetcherInfo fetcher_info, SSHAuthenticationInfo auth_info) : base (fetcher_info)
|
2011-05-31 01:26:57 +00:00
|
|
|
{
|
2016-04-04 09:27:20 +00:00
|
|
|
this.auth_info = auth_info;
|
2016-04-05 07:52:16 +00:00
|
|
|
var uri_builder = new UriBuilder (RemoteUrl);
|
2016-04-04 09:27:20 +00:00
|
|
|
|
2016-04-05 07:52:16 +00:00
|
|
|
if (!RemoteUrl.Scheme.Equals ("ssh") && !RemoteUrl.Scheme.Equals ("git"))
|
|
|
|
uri_builder.Scheme = "ssh";
|
2012-12-21 21:02:35 +00:00
|
|
|
|
2016-04-05 07:52:16 +00:00
|
|
|
if (RemoteUrl.Host.Equals ("github.com")) {
|
|
|
|
uri_builder.Scheme = "ssh";
|
|
|
|
uri_builder.UserName = "git";
|
2011-05-31 01:26:57 +00:00
|
|
|
|
2016-04-05 07:52:16 +00:00
|
|
|
} else if (string.IsNullOrEmpty (RemoteUrl.UserInfo)) {
|
|
|
|
uri_builder.UserName = "storage";
|
2011-05-31 01:26:57 +00:00
|
|
|
}
|
|
|
|
|
2016-04-05 07:52:16 +00:00
|
|
|
RemoteUrl = uri_builder.Uri;
|
2011-05-31 01:26:57 +00:00
|
|
|
}
|
2011-05-16 20:19:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
public override bool Fetch ()
|
|
|
|
{
|
2013-04-27 12:02:54 +00:00
|
|
|
if (!base.Fetch ())
|
|
|
|
return false;
|
|
|
|
|
2012-04-12 22:44:31 +00:00
|
|
|
if (FetchPriorHistory) {
|
2016-04-05 07:55:11 +00:00
|
|
|
git_clone = new GitCommand (Configuration.DefaultConfig.TmpPath,
|
2016-04-04 09:27:20 +00:00
|
|
|
"clone --progress --no-checkout \"" + RemoteUrl + "\" \"" + TargetFolder + "\"", auth_info);
|
2012-03-29 00:44:26 +00:00
|
|
|
|
|
|
|
} else {
|
2016-04-05 07:55:11 +00:00
|
|
|
git_clone = new GitCommand (Configuration.DefaultConfig.TmpPath,
|
2016-04-04 09:27:20 +00:00
|
|
|
"clone --progress --no-checkout --depth=1 \"" + RemoteUrl + "\" \"" + TargetFolder + "\"", auth_info);
|
2012-03-29 00:44:26 +00:00
|
|
|
}
|
2012-04-11 18:07:34 +00:00
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
git_clone.StartInfo.RedirectStandardError = true;
|
|
|
|
git_clone.Start ();
|
2011-12-18 16:10:06 +00:00
|
|
|
|
2011-08-27 15:53:17 +00:00
|
|
|
double percentage = 1.0;
|
2011-12-30 00:44:35 +00:00
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
var last_change = DateTime.Now;
|
|
|
|
var change_interval = new TimeSpan (0, 0, 0, 1);
|
2011-12-30 00:44:35 +00:00
|
|
|
|
2013-06-20 20:01:03 +00:00
|
|
|
try {
|
2016-04-05 07:55:11 +00:00
|
|
|
while (!git_clone.StandardError.EndOfStream) {
|
|
|
|
string line = git_clone.StandardError.ReadLine ();
|
|
|
|
Match match = progress_regex.Match (line);
|
2015-01-13 22:20:50 +00:00
|
|
|
|
2013-06-20 20:01:03 +00:00
|
|
|
double number = 0.0;
|
2015-01-13 22:20:50 +00:00
|
|
|
double speed = 0.0;
|
2013-06-20 20:01:03 +00:00
|
|
|
if (match.Success) {
|
2013-08-25 16:46:06 +00:00
|
|
|
try {
|
|
|
|
number = double.Parse (match.Groups [1].Value, new CultureInfo ("en-US"));
|
2015-01-13 22:20:50 +00:00
|
|
|
|
2013-08-25 16:46:06 +00:00
|
|
|
} catch (FormatException) {
|
2016-03-30 23:36:31 +00:00
|
|
|
Logger.LogInfo ("Git", "Error parsing progress: \"" + match.Groups [1] + "\"");
|
2013-08-25 16:46:06 +00:00
|
|
|
}
|
2015-01-13 22:20:50 +00:00
|
|
|
|
2013-08-25 16:46:06 +00:00
|
|
|
// The pushing progress consists of two stages: the "Compressing
|
|
|
|
// objects" stage which we count as 20% of the total progress, and
|
|
|
|
// the "Writing objects" stage which we count as the last 80%
|
|
|
|
if (line.Contains ("Compressing")) {
|
|
|
|
// "Compressing objects" stage
|
|
|
|
number = (number / 100 * 20);
|
2015-01-13 22:20:50 +00:00
|
|
|
|
2013-08-25 16:46:06 +00:00
|
|
|
} else {
|
|
|
|
// "Writing objects" stage
|
|
|
|
number = (number / 100 * 80 + 20);
|
2016-04-05 07:55:11 +00:00
|
|
|
Match speed_match = speed_regex.Match (line);
|
2015-01-13 22:20:50 +00:00
|
|
|
|
2013-08-25 16:46:06 +00:00
|
|
|
if (speed_match.Success) {
|
|
|
|
try {
|
|
|
|
speed = double.Parse (speed_match.Groups [1].Value, new CultureInfo ("en-US")) * 1024;
|
|
|
|
|
|
|
|
} catch (FormatException) {
|
2016-03-30 23:36:31 +00:00
|
|
|
Logger.LogInfo ("Git", "Error parsing speed: \"" + speed_match.Groups [1] + "\"");
|
2013-08-25 16:46:06 +00:00
|
|
|
}
|
2015-01-13 22:20:50 +00:00
|
|
|
|
2013-08-25 16:46:06 +00:00
|
|
|
if (speed_match.Groups [2].Value.Equals ("M"))
|
|
|
|
speed = speed * 1024;
|
2015-01-13 22:20:50 +00:00
|
|
|
}
|
2013-08-25 16:46:06 +00:00
|
|
|
}
|
2013-06-20 20:01:03 +00:00
|
|
|
|
|
|
|
} else {
|
2016-03-30 23:36:31 +00:00
|
|
|
Logger.LogInfo ("Fetcher", line);
|
2013-06-20 20:01:03 +00:00
|
|
|
line = line.Trim (new char [] {' ', '@'});
|
|
|
|
|
|
|
|
if (line.StartsWith ("fatal:", StringComparison.InvariantCultureIgnoreCase) ||
|
|
|
|
line.StartsWith ("error:", StringComparison.InvariantCultureIgnoreCase)) {
|
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
errors.Add (line);
|
2013-06-20 20:01:03 +00:00
|
|
|
|
|
|
|
} else if (line.StartsWith ("WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!")) {
|
2016-04-05 07:55:11 +00:00
|
|
|
errors.Add ("warning: Remote host identification has changed!");
|
2013-06-20 20:01:03 +00:00
|
|
|
|
|
|
|
} else if (line.StartsWith ("WARNING: POSSIBLE DNS SPOOFING DETECTED!")) {
|
2016-04-05 07:55:11 +00:00
|
|
|
errors.Add ("warning: Possible DNS spoofing detected!");
|
2013-06-20 20:01:03 +00:00
|
|
|
}
|
2012-06-17 21:57:15 +00:00
|
|
|
}
|
2012-04-17 09:05:47 +00:00
|
|
|
|
2013-06-20 20:01:03 +00:00
|
|
|
if (number >= percentage) {
|
|
|
|
percentage = number;
|
2011-12-30 00:44:35 +00:00
|
|
|
|
2013-06-20 20:01:03 +00:00
|
|
|
if (DateTime.Compare (last_change, DateTime.Now.Subtract (change_interval)) < 0) {
|
2016-04-05 07:55:11 +00:00
|
|
|
OnProgressChanged (percentage, speed);
|
2013-06-20 20:01:03 +00:00
|
|
|
last_change = DateTime.Now;
|
|
|
|
}
|
2011-12-30 00:44:35 +00:00
|
|
|
}
|
2011-08-27 15:53:17 +00:00
|
|
|
}
|
2015-01-13 22:20:50 +00:00
|
|
|
|
2013-06-26 09:11:03 +00:00
|
|
|
} catch (Exception) {
|
2013-06-20 20:01:03 +00:00
|
|
|
IsActive = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
git_clone.WaitForExit ();
|
2012-06-17 20:56:27 +00:00
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
if (git_clone.ExitCode != 0)
|
|
|
|
return false;
|
2012-06-17 20:56:27 +00:00
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
while (percentage < 100) {
|
|
|
|
percentage += 25;
|
2012-04-22 12:32:55 +00:00
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
if (percentage >= 100)
|
|
|
|
break;
|
2012-06-17 20:56:27 +00:00
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
Thread.Sleep (500);
|
|
|
|
OnProgressChanged (percentage, 0);
|
|
|
|
}
|
2011-12-30 00:44:35 +00:00
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
OnProgressChanged (100, 0);
|
2012-06-17 20:56:27 +00:00
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
InstallConfiguration ();
|
|
|
|
InstallExcludeRules ();
|
|
|
|
InstallAttributeRules ();
|
|
|
|
InstallGitLFS ();
|
2012-02-26 15:58:09 +00:00
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
return true;
|
2011-05-16 20:19:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 20:47:46 +00:00
|
|
|
public override void Stop ()
|
|
|
|
{
|
2012-04-11 10:51:53 +00:00
|
|
|
try {
|
2016-04-05 07:55:11 +00:00
|
|
|
if (git_clone != null && !git_clone.HasExited) {
|
|
|
|
git_clone.Kill ();
|
|
|
|
git_clone.Dispose ();
|
2012-10-05 19:55:57 +00:00
|
|
|
}
|
2012-04-11 10:51:53 +00:00
|
|
|
|
|
|
|
} catch (Exception e) {
|
2016-03-30 23:36:31 +00:00
|
|
|
Logger.LogInfo ("Fetcher", "Failed to dispose properly", e);
|
2011-08-26 20:47:46 +00:00
|
|
|
}
|
2013-06-30 14:48:35 +00:00
|
|
|
|
|
|
|
if (Directory.Exists (TargetFolder)) {
|
|
|
|
try {
|
|
|
|
Directory.Delete (TargetFolder, true /* Recursive */ );
|
2016-03-30 23:36:31 +00:00
|
|
|
Logger.LogInfo ("Fetcher", "Deleted '" + TargetFolder + "'");
|
2015-01-13 22:20:50 +00:00
|
|
|
|
2013-06-30 14:48:35 +00:00
|
|
|
} catch (Exception e) {
|
2016-03-30 23:36:31 +00:00
|
|
|
Logger.LogInfo ("Fetcher", "Failed to delete '" + TargetFolder + "'", e);
|
2013-06-30 14:48:35 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-18 09:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-22 12:32:55 +00:00
|
|
|
public override void Complete ()
|
2012-04-18 09:52:45 +00:00
|
|
|
{
|
2012-07-05 11:33:32 +00:00
|
|
|
if (!IsFetchedRepoEmpty) {
|
2016-04-02 09:59:36 +00:00
|
|
|
string branch = "HEAD";
|
|
|
|
string prefered_branch = "SparkleShare";
|
|
|
|
|
|
|
|
// Prefer the "SparkleShare" branch if it exists
|
|
|
|
var git_show_ref = new GitCommand (TargetFolder, "show-ref --verify --quiet refs/heads/" + prefered_branch);
|
|
|
|
git_show_ref.StartAndWaitForExit ();
|
|
|
|
|
|
|
|
if (git_show_ref.ExitCode == 0)
|
|
|
|
branch = prefered_branch;
|
|
|
|
|
|
|
|
var git_checkout = new GitCommand (TargetFolder, "checkout --quiet " + branch);
|
|
|
|
git_checkout.StartAndWaitForExit ();
|
2012-07-05 11:33:32 +00:00
|
|
|
}
|
2012-06-10 22:56:39 +00:00
|
|
|
|
2012-07-05 11:33:32 +00:00
|
|
|
base.Complete ();
|
2011-08-26 20:47:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-28 17:14:21 +00:00
|
|
|
void InstallConfiguration ()
|
2011-05-16 20:19:58 +00:00
|
|
|
{
|
2016-03-31 14:46:17 +00:00
|
|
|
string [] settings = {
|
2014-11-08 12:21:37 +00:00
|
|
|
"core.autocrlf input",
|
2012-06-29 12:17:59 +00:00
|
|
|
"core.quotepath false", // Don't quote "unusual" characters in path names
|
|
|
|
"core.ignorecase false", // Be case sensitive explicitly to work on Mac
|
|
|
|
"core.filemode false", // Ignore permission changes
|
2012-11-08 16:02:55 +00:00
|
|
|
"core.precomposeunicode true", // Use the same Unicode form on all filesystems
|
2012-06-29 12:17:59 +00:00
|
|
|
"core.safecrlf false",
|
2013-07-06 18:05:12 +00:00
|
|
|
"core.excludesfile \"\"",
|
2012-06-29 12:17:59 +00:00
|
|
|
"core.packedGitLimit 128m", // Some memory limiting options
|
|
|
|
"core.packedGitWindowSize 128m",
|
|
|
|
"pack.deltaCacheSize 128m",
|
|
|
|
"pack.packSizeLimit 128m",
|
2012-10-26 12:43:54 +00:00
|
|
|
"pack.windowMemory 128m",
|
|
|
|
"push.default matching"
|
2012-06-29 11:53:13 +00:00
|
|
|
};
|
2012-06-28 23:12:37 +00:00
|
|
|
|
2016-03-31 08:35:26 +00:00
|
|
|
if (InstallationInfo.Platform == PlatformID.Win32NT)
|
2014-11-08 12:21:37 +00:00
|
|
|
settings [0] = "core.autocrlf true";
|
|
|
|
|
2012-06-29 12:17:59 +00:00
|
|
|
foreach (string setting in settings) {
|
2016-04-05 07:55:11 +00:00
|
|
|
var git_config = new GitCommand (TargetFolder, "config " + setting);
|
2012-07-26 10:12:14 +00:00
|
|
|
git_config.StartAndWaitForExit ();
|
2012-06-29 11:53:13 +00:00
|
|
|
}
|
2011-05-16 20:19:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-28 17:14:21 +00:00
|
|
|
public override void EnableFetchedRepoCrypto (string password)
|
|
|
|
{
|
2016-04-05 07:55:11 +00:00
|
|
|
var git_config_smudge = new GitCommand (TargetFolder,
|
2016-03-28 18:53:45 +00:00
|
|
|
"config filter.encryption.smudge \"openssl enc -d -aes-256-cbc -base64" + " " +
|
2016-04-05 07:55:11 +00:00
|
|
|
"-S " + password.SHA256 (password_salt).Substring (0, 16) + " " +
|
2016-03-28 17:14:21 +00:00
|
|
|
"-pass file:.git/info/encryption_password\"");
|
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
var git_config_clean = new GitCommand (TargetFolder,
|
2016-03-28 18:53:45 +00:00
|
|
|
"config filter.encryption.clean \"openssl enc -e -aes-256-cbc -base64" + " " +
|
2016-04-05 07:55:11 +00:00
|
|
|
"-S " + password.SHA256 (password_salt).Substring (0, 16) + " " +
|
2016-03-28 17:14:21 +00:00
|
|
|
"-pass file:.git/info/encryption_password\"");
|
|
|
|
|
|
|
|
git_config_smudge.StartAndWaitForExit ();
|
|
|
|
git_config_clean.StartAndWaitForExit ();
|
|
|
|
|
|
|
|
// Pass all files through the encryption filter
|
2016-03-31 14:46:17 +00:00
|
|
|
string git_attributes_file_path = Path.Combine (TargetFolder, ".git", "info", "attributes");
|
2016-03-28 17:14:21 +00:00
|
|
|
File.WriteAllText (git_attributes_file_path, "* filter=encryption");
|
|
|
|
|
|
|
|
// Store the password
|
2016-03-31 14:46:17 +00:00
|
|
|
string password_file_path = Path.Combine (TargetFolder, ".git", "info", "encryption_password");
|
2016-04-05 07:55:11 +00:00
|
|
|
File.WriteAllText (password_file_path, password.SHA256 (password_salt));
|
2016-03-28 17:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool IsFetchedRepoPasswordCorrect (string password)
|
|
|
|
{
|
|
|
|
string password_check_file_path = Path.Combine (TargetFolder, ".sparkleshare");
|
|
|
|
|
|
|
|
if (!File.Exists (password_check_file_path)) {
|
2016-04-05 07:55:11 +00:00
|
|
|
var git_show = new GitCommand (TargetFolder, "show HEAD:.sparkleshare");
|
|
|
|
string output = git_show.StartAndReadStandardOutput ();
|
2016-03-28 17:14:21 +00:00
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
if (git_show.ExitCode == 0)
|
2016-03-28 17:14:21 +00:00
|
|
|
File.WriteAllText (password_check_file_path, output);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-05 07:55:11 +00:00
|
|
|
string args = "enc -d -aes-256-cbc -base64 -salt -pass pass:" + password.SHA256 (password_salt) + " " +
|
2016-03-28 17:14:21 +00:00
|
|
|
"-in \"" + password_check_file_path + "\"";
|
|
|
|
|
2016-03-30 23:36:31 +00:00
|
|
|
var process = new Command ("openssl", args);
|
2016-03-28 18:36:19 +00:00
|
|
|
process.StartInfo.WorkingDirectory = TargetFolder;
|
2016-03-28 17:14:21 +00:00
|
|
|
|
|
|
|
process.StartAndWaitForExit ();
|
|
|
|
|
|
|
|
if (process.ExitCode == 0) {
|
|
|
|
File.Delete (password_check_file_path);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2016-04-05 07:55:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
void InstallExcludeRules ()
|
|
|
|
{
|
|
|
|
string git_info_path = Path.Combine (TargetFolder, ".git", "info");
|
|
|
|
|
|
|
|
if (!Directory.Exists (git_info_path))
|
|
|
|
Directory.CreateDirectory (git_info_path);
|
|
|
|
|
|
|
|
string exclude_rules = string.Join (Environment.NewLine, ExcludeRules);
|
|
|
|
string exclude_rules_file_path = Path.Combine (git_info_path, "exclude");
|
|
|
|
|
|
|
|
File.WriteAllText (exclude_rules_file_path, exclude_rules);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InstallAttributeRules ()
|
|
|
|
{
|
|
|
|
string attribute_rules_file_path = Path.Combine (TargetFolder, ".git", "info", "attributes");
|
|
|
|
TextWriter writer = new StreamWriter (attribute_rules_file_path);
|
|
|
|
|
|
|
|
// Compile a list of files we don't want Git to compress. Not compressing
|
|
|
|
// already compressed files decreases memory usage and increases speed
|
|
|
|
string [] extensions = {
|
|
|
|
"jpg", "jpeg", "png", "tiff", "gif", // Images
|
|
|
|
"flac", "mp3", "ogg", "oga", // Audio
|
|
|
|
"avi", "mov", "mpg", "mpeg", "mkv", "ogv", "ogx", "webm", // Video
|
|
|
|
"zip", "gz", "bz", "bz2", "rpm", "deb", "tgz", "rar", "ace", "7z", "pak", "tc", "iso", ".dmg" // Archives
|
|
|
|
};
|
|
|
|
|
|
|
|
foreach (string extension in extensions) {
|
|
|
|
writer.WriteLine ("*." + extension + " -delta");
|
|
|
|
writer.WriteLine ("*." + extension.ToUpper () + " -delta");
|
|
|
|
}
|
|
|
|
|
|
|
|
writer.WriteLine ("*.txt text");
|
|
|
|
writer.WriteLine ("*.TXT text");
|
|
|
|
writer.Close ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InstallGitLFS ()
|
|
|
|
{
|
|
|
|
var git_lfs = new GitCommand (TargetFolder, "lfs install --local");
|
|
|
|
git_lfs.StartAndWaitForExit ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EnableGitLFS ()
|
|
|
|
{
|
|
|
|
string git_attributes_file_path = Path.Combine (TargetFolder, ".gitattributes");
|
|
|
|
File.WriteAllText (git_attributes_file_path, "* filter=lfs diff=lfs merge=lfs -text");
|
|
|
|
}
|
2011-05-16 20:19:58 +00:00
|
|
|
}
|
|
|
|
}
|