Skip to content

Clone remote repository. #1548

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

Merged
merged 67 commits into from
Jun 24, 2025
Merged

Clone remote repository. #1548

merged 67 commits into from
Jun 24, 2025

Conversation

jeremypw
Copy link
Collaborator

@jeremypw jeremypw commented Apr 3, 2025

  • Add clone action and associated menuitem
  • Put "Clone" menuitem in ProjectChooser menu
  • Move "Open Project" menuitem into ProjectChooser menu
  • Use dialog to get remote uri and local target (partially validated)
  • Persist default remote and local projects folder entries
  • Show spinner while cloning is ongoing, do not block UI
  • If cloning fails show error dialog giving opportunity to amend and retry
  • On success, open the new project folder but do not make it active (similar to "Open Project" action)

Screenshot from 2025-06-05 12 26 58
Screenshot from 2025-06-05 12 28 23
Screenshot from 2025-06-05 12 29 28

@jeremypw jeremypw marked this pull request as ready for review May 18, 2025 16:06
@jeremypw jeremypw mentioned this pull request May 26, 2025
14 tasks
@jeremypw jeremypw requested a review from a team May 27, 2025 15:44
danirabbit

This comment was marked as resolved.

@jeremypw
Copy link
Collaborator Author

@danirabbit Thanks for the detailed review! I'll get working on your comments. Regarding the dialog, I was trying to reduce the amount of typing required to specify the remote URL especially if you are cloning an elementary repository. I too usually copy paste the URL from github because I use the terminal command git clone .. anyway. I was trying to make the UI easier by only having to type the name of the project for the default situation but if it confuses then maybe I should just have one entry for the URL? I'll rethink the dialog.

@jeremypw jeremypw mentioned this pull request Jun 20, 2025
@jeremypw jeremypw changed the title Add functionality to clone remote repository. Clone remote repository. Jun 20, 2025
@jeremypw jeremypw added this to the 8.1 milestone Jun 20, 2025
Copy link
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

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

Just two things and then I think it's good to get in for more testing

@@ -112,5 +112,38 @@ namespace Scratch.Services {

return build_path;
}

//TODO Make this a real async function that does not block the main loop.
Copy link
Member

@danirabbit danirabbit Jun 20, 2025

Choose a reason for hiding this comment

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

I think this needs to be done before this is ready to merge. Otherwise Gala thinks Code has crashed while it's cloning

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done but Gala still thinks Code has crashed because the underlying Ggit function is still synchronous and there is no obvious way of interrupting it. Once it has started it dominates the cpu. I'll try to find a solution as this affects other apps too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looks like we need to use a real GLib.Thread. Async functions run in the same thread as the main loop so can block the UI.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now using a GLib.Thread to wrap the Ggit.clone (). Seems to work (as judged by spinner operating smoothly during cloning)

@jeremypw jeremypw requested a review from danirabbit June 23, 2025 11:14
Copy link
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

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

Somewhere along the way we seem to have lost "activates default" on entries

// - Can contain only letters ( a-zA-Z ), digits ( 0-9 ), underscores ( _ ), dots ( . ), or dashes ( - ).
// - Must not contain consecutive special characters.
// - Cannot end in . git or . atom .
private const string CLONE_REPOSITORY = N_("Clone Button");
Copy link
Member

Choose a reason for hiding this comment

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

This is not right:

Screenshot from 2025-06-23 11 28 00

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, left over from testing...

Comment on lines 32 to 49
public bool cloning_in_progress {
set {
if (value) {
clone_button.label = _(CLONING);
spinner.start ();

} else {
clone_button.label = _(CLONE_REPOSITORY);
spinner.stop ();
}

revealer.reveal_child = value;
}

get {
return revealer.reveal_child;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This is definitely not right. You could add another page with a spinner, but keeping everything sensitive and changing the button label is definitely not good

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, the spinner at this point is a proof of principle that the cloning thread was not blocking the UI. I wasn't sure how to show it in practise. I'll show another page as you suggest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now implemented simple separate page

Comment on lines 138 to 140
clone_button = new Gtk.Button.with_label (_(CLONE_REPOSITORY));
clone_button.show ();
add_action_widget (clone_button, Gtk.ResponseType.APPLY);
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be

Suggested change
clone_button = new Gtk.Button.with_label (_(CLONE_REPOSITORY));
clone_button.show ();
add_action_widget (clone_button, Gtk.ResponseType.APPLY);
clone_button = add_button (_(CLONE_REPOSITORY), Gtk.ResponseType.APPLY);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Included in my commit

@jeremypw
Copy link
Collaborator Author

@danirabbit Thanks for the thorough review. Hopefully most of the essential issues are fixed now. The "cloning in progress" page is minimal but can be improved before the next release hopefully. I am still unsure whether it is correct to focus the "Cancel" button rather than the URI entry on opening. I have reinstated the "activates-default" behaviour although there is a small risk of starting to clone into the wrong folder if the intention is to clone into a non-default location.

@jeremypw jeremypw requested a review from danirabbit June 24, 2025 09:22
@jeremypw
Copy link
Collaborator Author

There doesn't seem to be a way of cancelling an ongoing cloning process afaict.

@jeremypw
Copy link
Collaborator Author

I have a PR demonstrating use of Ggit.RemoveCallbacks to give more detailed info during cloning here #1608, but needs design work and I don't want to hold this PR.

Copy link
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

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

Let's go 🚀

@danirabbit danirabbit merged commit 34b0af4 into master Jun 24, 2025
6 checks passed
@danirabbit danirabbit deleted the jeremypw/implement-clone branch June 24, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants