Add option to add projects without full history (git: --depth=1)

This commit is contained in:
Hylke Bons 2012-03-29 01:44:26 +01:00
parent ee23914de2
commit bad4bf9a46
5 changed files with 46 additions and 14 deletions

View file

@ -29,10 +29,11 @@ namespace SparkleLib.Git {
public class SparkleFetcher : SparkleFetcherBase {
private SparkleGit git;
private bool fetch_prior_history = false;
public SparkleFetcher (string server, string remote_path, string target_folder) :
base (server, remote_path, target_folder)
public SparkleFetcher (string server, string remote_path, string target_folder, bool fetch_prior_history) :
base (server, remote_path, target_folder, fetch_prior_history)
{
remote_path = remote_path.Trim ("/".ToCharArray ());
@ -87,15 +88,26 @@ namespace SparkleLib.Git {
TargetFolder = target_folder;
RemoteUrl = uri.ToString ();
this.fetch_prior_history = fetch_prior_history;
}
public override bool Fetch ()
{
this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath,
"clone " +
"--progress " + // Redirects progress stats to standarderror
"\"" + RemoteUrl + "\" \"" + TargetFolder + "\"");
if (this.fetch_prior_history) {
this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath,
"clone " +
"--progress " +
"--depth=1 " +
"\"" + RemoteUrl + "\" \"" + TargetFolder + "\"");
} else {
this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath,
"clone " +
"--progress " +
"\"" + RemoteUrl + "\" \"" + TargetFolder + "\"");
}
this.git.StartInfo.RedirectStandardError = true;
this.git.Start ();

View file

@ -47,7 +47,8 @@ namespace SparkleLib {
private Thread thread;
public SparkleFetcherBase (string server, string remote_folder, string target_folder)
public SparkleFetcherBase (string server, string remote_folder,
string target_folder, bool fetch_prior_history)
{
TargetFolder = target_folder;
RemoteUrl = server + "/" + remote_folder;

View file

@ -380,14 +380,14 @@ namespace SparkleLib {
SyncStatusChanged (SyncStatus.Error);
}
this.progress_percentage = 0.0;
this.progress_speed = "";
if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.Idle);
this.remote_timer.Start ();
EnableWatching ();
this.progress_percentage = 0.0;
this.progress_speed = "";
}

View file

@ -951,7 +951,8 @@ namespace SparkleShare {
}
public void FetchFolder (string address, string remote_path, string announcements_url)
public void FetchFolder (string address, string remote_path, string announcements_url,
bool fetch_prior_history)
{
if (announcements_url != null)
announcements_url = announcements_url.Trim ();
@ -983,7 +984,8 @@ namespace SparkleShare {
Type.GetType ("SparkleLib." + backend + ".SparkleFetcher, SparkleLib." + backend),
address,
remote_path,
tmp_folder
tmp_folder,
fetch_prior_history
);
} catch {

View file

@ -100,10 +100,17 @@ namespace SparkleShare {
}
}
public bool FetchPriorHistory {
get {
return this.fetch_prior_history;
}
}
private string saved_address = "";
private string saved_remote_path = "";
private bool create_startup_item = true;
private bool fetch_prior_history = false;
public SparkleSetupController ()
@ -184,6 +191,8 @@ namespace SparkleShare {
PreviousPath = "";
PreviousUrl = "";
this.fetch_prior_history = false;
if (HideWindowEvent != null)
HideWindowEvent ();
}
@ -238,6 +247,12 @@ namespace SparkleShare {
}
public void HistoryItemChanged (bool fetch_prior_history)
{
this.fetch_prior_history = fetch_prior_history;
}
public void TutorialPageCompleted ()
{
TutorialPageNumber++;
@ -330,7 +345,8 @@ namespace SparkleShare {
Program.Controller.FolderFetchError += AddPageFetchErrorDelegate;
Program.Controller.FolderFetching += SyncingPageFetchingDelegate;
Program.Controller.FetchFolder (address, remote_path, SelectedPlugin.AnnouncementsUrl);
Program.Controller.FetchFolder (address, remote_path,
SelectedPlugin.AnnouncementsUrl, this.fetch_prior_history);
}
// The following private methods are
@ -411,7 +427,7 @@ namespace SparkleShare {
Program.Controller.FolderFetching += SyncingPageFetchingDelegate;
Program.Controller.FetchFolder (PendingInvite.Address,
PendingInvite.RemotePath, PendingInvite.AnnouncementsUrl);
PendingInvite.RemotePath, PendingInvite.AnnouncementsUrl, false); // TODO: checkbox on invite page
}
// The following private methods are
@ -482,6 +498,7 @@ namespace SparkleShare {
PreviousUrl = "";
PreviousAddress = "";
PreviousPath = "";
this.fetch_prior_history = false;
Program.Controller.UpdateState ();