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
35 changes: 33 additions & 2 deletions src/Chorus/UI/Clone/GetCloneFromInternetDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,43 @@ private void _cancelButton_Click(object sender, EventArgs e)
}

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


/// <summary>
/// Starts 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 of the project to clone</param>
Copy link
Contributor

Choose a reason for hiding this comment

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

How about: "Name for the project on the local machine"?

When I read, "Project to clone," I think of the name on the server.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure!

/// <param name="projectUri">URI where the project can be found</param>
/// </summary>
public static GetCloneFromInternetDialog StartClone(string username, string password, string projectFolder, string projectName, Uri projectUri)
Copy link
Contributor

Choose a reason for hiding this comment

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

CloneResult would be a better return type; the client shouldn't have to dig figure out what happened. Since that would make this method handle the whole process, it should be renamed to DoClone

Copy link
Collaborator Author

@josephmyers josephmyers Oct 6, 2023

Choose a reason for hiding this comment

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

I'm concerned about removing the Form return result, at first glance. FB needs to provide Application.Run() with something to keep from moving on immediately. Maybe it's just as simple as moving that call in here? I'll look into it. Edit: Everything hunky-dory!

Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicking: This dialog seems kind of a funny place for this method. I'd consider GetSharedProjectModel or even a new class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you'd like me to move it, let me know where. (It doesn't matter too much to me.) I put it here, because it needs the model and dialog, both of which are present here. But its being static now makes separation easier

{
var model = new GetCloneFromInternetModel(projectFolder)
{
Username = username,
Password = password,
CustomUrl = projectUri.ToString(),
IsCustomUrl = true,
LocalFolderName = projectName
};

var dialog = new GetCloneFromInternetDialog(model);
dialog.Show();
dialog.StartClone();

return dialog;
}

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


public string ThreadSafeUrl
{
get;
Expand Down
Loading