This repository has been archived by the owner on Mar 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from RenderHeads/master
Credentials, LFS, Full reimport, -7 error fix, misc fixes.
- Loading branch information
Showing
18 changed files
with
522 additions
and
72 deletions.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,7 +239,6 @@ List<string> DirectoryCopy(string sourceDirName, string destDirName, string[] fo | |
} | ||
} | ||
|
||
|
||
public void CopyBackChanges() | ||
{ | ||
//Swapped from forward copy. Other logic can stay the same. | ||
|
@@ -298,6 +297,7 @@ void DirectoryCopy(string sourceDirName, string destDirName) | |
} | ||
} | ||
} | ||
|
||
public void CancelUpdate() | ||
{ | ||
if(_inProgress) _cancellationPending = true; | ||
|
@@ -324,7 +324,6 @@ public bool LastOperationSuccess | |
} | ||
} | ||
|
||
|
||
public bool CancellationPending | ||
{ | ||
get | ||
|
@@ -380,13 +379,13 @@ private void UpdateTask(object stateInfo) | |
|
||
FetchOptions fetchOptions = new FetchOptions() | ||
{ | ||
TagFetchMode = TagFetchMode.All, | ||
/*TagFetchMode = TagFetchMode.All, | ||
OnTransferProgress = new LibGit2Sharp.Handlers.TransferProgressHandler((progress) => | ||
{ | ||
_progressQueue.Enqueue(new Progress(((float)progress.ReceivedObjects) / progress.TotalObjects, "Fetching " + progress.ReceivedObjects + "/" + progress.TotalObjects + "(" + progress.ReceivedBytes + " bytes )")); | ||
return _cancellationPending; | ||
}), | ||
}),*/ | ||
CredentialsProvider = (credsUrl, user, supportedCredentials) => | ||
{ | ||
state.CredentialManager.GetCredentials(credsUrl, user, supportedCredentials, out var credentials, out string message); | ||
|
@@ -401,10 +400,10 @@ private void UpdateTask(object stateInfo) | |
//Repo exists we are doing a pull | ||
using (var repo = new LibGit2Sharp.Repository(state.LocalDestination)) | ||
{ | ||
_progressQueue.Enqueue(new Progress(0, "Nuking local changes. Checking out " + state.Branch)); | ||
//_progressQueue.Enqueue(new Progress(0, "Nuking local changes. Checking out " + state.Branch)); | ||
|
||
Branch branch = repo.Branches[state.Branch]; | ||
Commands.Checkout(repo, branch, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force, CheckoutNotifyFlags = CheckoutNotifyFlags.None}); | ||
//Branch branch = repo.Branches[state.Branch]; | ||
//Commands.Checkout(repo, branch, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force, CheckoutNotifyFlags = CheckoutNotifyFlags.None}); | ||
|
||
// Credential information to fetch | ||
PullOptions options = new PullOptions | ||
|
@@ -414,7 +413,7 @@ private void UpdateTask(object stateInfo) | |
|
||
// User information to create a merge commit. Should not happen as we force checkout before pulling. | ||
var signature = new LibGit2Sharp.Signature( | ||
new Identity("MergeNotAllowed", "MergeNotAllowed@MergeMail.com"), DateTimeOffset.Now); | ||
new Identity("RepositoryManager", "repositorymanager@mergemail.com"), DateTimeOffset.Now); | ||
|
||
try | ||
{ | ||
|
@@ -428,6 +427,37 @@ private void UpdateTask(object stateInfo) | |
_progressQueue.Enqueue(new Progress(0, "Pull failed: " + e.Message)); | ||
_lastOperationSuccess = false; | ||
} | ||
|
||
/*try | ||
{ | ||
var remote = repo.Network.Remotes["origin"]; | ||
var refSpecs = remote.FetchRefSpecs.Select(x => x.Specification); | ||
_progressQueue.Enqueue(new Progress(0, "Fetching from " + remote.Name)); | ||
Commands.Fetch(repo, remote.Name, refSpecs, fetchOptions, ""); | ||
_progressQueue.Enqueue(new Progress(1, "Complete")); | ||
try | ||
{ | ||
Branch branch = repo.Branches["origin/" + state.Branch]; | ||
var signature = new Signature(new Identity("RepositoryManager", "[email protected]"), DateTimeOffset.Now); | ||
repo.Merge(branch, signature); | ||
_lastOperationSuccess = true; | ||
} | ||
catch (Exception e) | ||
{ | ||
_progressQueue.Enqueue(new Progress(0, "Merge failed: " + e.Message)); | ||
_lastOperationSuccess = false; | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
_progressQueue.Enqueue(new Progress(0, "Fetch failed: " + e.Message)); | ||
_lastOperationSuccess = false; | ||
}*/ | ||
} | ||
} | ||
else | ||
|
@@ -471,6 +501,20 @@ private void UpdateTask(object stateInfo) | |
} | ||
} | ||
|
||
if(LastOperationSuccess) | ||
{ | ||
_progressQueue.Enqueue(new Progress(1, "Downloading LFS files")); | ||
try | ||
{ | ||
InstallAndPullLFS(state.LocalDestination); | ||
} | ||
catch(Exception e) | ||
{ | ||
_progressQueue.Enqueue(new Progress(0, "LFS Pull failed: " + e.Message)); | ||
_lastOperationSuccess = false; | ||
} | ||
} | ||
|
||
//Once completed | ||
_inProgress = false; | ||
_cancellationPending = false; | ||
|
@@ -486,5 +530,52 @@ public void OpenRepositoryDestination() | |
}); | ||
//Leave the process running. User should close it manually. | ||
} | ||
|
||
public void InstallAndPullLFS(string path) | ||
{ | ||
//Install lfs | ||
ProcessStartInfo installStartInfo = new ProcessStartInfo | ||
{ | ||
FileName = "git-lfs", | ||
Arguments = "install", | ||
WorkingDirectory = path, | ||
UseShellExecute = false, | ||
WindowStyle = ProcessWindowStyle.Hidden, | ||
CreateNoWindow = true, | ||
RedirectStandardInput = true, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true | ||
}; | ||
|
||
Process installProcess = new Process | ||
{ | ||
StartInfo = installStartInfo | ||
}; | ||
|
||
installProcess.Start(); | ||
installProcess.WaitForExit(); | ||
|
||
//Now pull lfs | ||
ProcessStartInfo pullStartInfo = new ProcessStartInfo | ||
{ | ||
FileName = "git-lfs", | ||
Arguments = "pull", | ||
WorkingDirectory = path, | ||
UseShellExecute = false, | ||
WindowStyle = ProcessWindowStyle.Hidden, | ||
CreateNoWindow = true, | ||
RedirectStandardInput = true, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true | ||
}; | ||
|
||
Process pullProcess = new Process | ||
{ | ||
StartInfo = pullStartInfo | ||
}; | ||
|
||
pullProcess.Start(); | ||
pullProcess.WaitForExit(); | ||
} | ||
} | ||
} |
Oops, something went wrong.