Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add public StartClone() method #325

Merged
merged 13 commits into from
Oct 13, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

- [SIL.Chorus.LibChorus] Add webm as additional audio file type
- [SIL.Chorus] Add ability to clone project without direct user interaction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"without user interaction": there's no indirect interaction, either.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my mind, the indirect user interaction is them using the wrapping software. They still have to do something to get the clone to happen.


### Changed

Expand Down
40 changes: 38 additions & 2 deletions src/Chorus/UI/Clone/GetCloneFromInternetDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,38 @@ public GetCloneFromInternetDialog(GetCloneFromInternetModel model)

}


/// <summary>
/// Performs a clone operation with the supplied information.
/// <param name="username">Username for Mercurial authentication</param>
/// <param name="password">Password for Mercurial authentication</param>
/// <param name="projectFolder">The parent directory to put the clone in</param>
/// <param name="projectName">Name for the project on the local machine</param>
/// <param name="projectUri">URI where the project can be found</param>
/// </summary>
public static CloneResult DoClone(string username, string password, string projectFolder, string projectName, Uri projectUri)
{
var model = new GetCloneFromInternetModel(projectFolder)
{
Username = username,
Password = password,
CustomUrl = projectUri.ToString(),
IsCustomUrl = true,
LocalFolderName = projectName
};

var dialog = new GetCloneFromInternetDialog(model);
DialogResult? res = null;
dialog.FormClosing += (sender, args) => res = dialog.DialogResult;

dialog.Show();
dialog.StartClone();
Application.Run(dialog);

var cloneStatus = res == DialogResult.OK ? CloneStatus.Created : CloneStatus.NotCreated;
return new CloneResult(dialog.PathToNewlyClonedFolder, cloneStatus);
}

private void _backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (_statusProgress.ErrorEncountered)
Expand Down Expand Up @@ -261,11 +293,16 @@ private void _cancelButton_Click(object sender, EventArgs e)
}

private void OnDownloadClick(object sender, EventArgs e)
{
StartClone();
}

private void StartClone()
{
lock (this)
{
_logBox.Clear();
if(_backgroundWorker.IsBusy)
if (_backgroundWorker.IsBusy)
return;
UpdateDisplay(State.MakingClone);
_model.SaveUserSettings();
Expand All @@ -275,7 +312,6 @@ private void OnDownloadClick(object sender, EventArgs e)
}
}


public string ThreadSafeUrl
{
get;
Expand Down
Loading