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 functionality for cloning from git in welcome view #232

Merged
merged 21 commits into from Apr 13, 2022

Conversation

Pythonen
Copy link
Member

@Pythonen Pythonen commented Mar 24, 2022

Description

This patch adds functionality for cloning a repository from the welcome view. Feel free to point out obvious mistakes as I am taking first touches with Swift world at the same time.

Related Issue

Checklist (for drafts):

  • UI might need some work
  • I read and understood the contributing guide as well as the code of conduct
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • Review requested

Screenshots (if appropriate):

Näyttökuva 2022-3-24 kello 18 50 47

Basics of cloning repository implemented. Pressing clone on welcome
view now opens simple window with url input with clone and close buttons

For now it clones the repositories in to your home dir. Error handling
for now is nada and should be implemented in later commits
Now you can select the folder to which you want to clone the repository.
This defaults to home folder.

Also added check that the repository isn't empty when trying to clone.
Now after we press `clone` button, we firstly clone the specified
repository to given folder. After cloning, we open folder picker for
the user to pick folder to open the editor in. However this could be better if
we straight up open the editor in the cloned folder, rather than giving user an option
to choose the folder in between.
Added error handling for git related errors e.g. when trying to clone
non existent repository
import GitClient
import Foundation

struct GitCloneView: View {
Copy link
Member

Choose a reason for hiding this comment

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

Consider adding this as a package in Modules

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was just writing this! ahah yeah, it would be awesome to have it on a module and a snapshot test alongside!

@lukepistrol lukepistrol added enhancement New feature or request UI This is UI related labels Mar 24, 2022
@lukepistrol lukepistrol linked an issue Mar 24, 2022 that may be closed by this pull request
@Angelk90
Copy link
Contributor

Angelk90 commented Mar 24, 2022

Hi @Pythonen , it would be nice to have this this thing this way:
Schermata 2022-03-24 alle 21 40 32

the possibility that the program has a menu like this, which by clicking on the button allows you to clone the project (whose http or git address was copied previously) and then to open the program.

Changed GitClone to be module as discussed in
CodeEditApp#232 (comment)
CodeEditModules/Package.swift Outdated Show resolved Hide resolved
@Pythonen
Copy link
Member Author

Pythonen commented Mar 25, 2022

I'm having a couple of 'bugs' in my current implementation. Gif helps to demonstrate.

  1. When using NSDocumentController to open the folder picker after cloning the repo, it opens in the wrong directory (probably the last dir I visited). I see this as a inconveniency in UX. Better would be to either open it in the cloned directory or even better, open the editor straight after cloning without the user having to explicitly choose.

  2. When finally opening the editor, the welcome view stays in the background.

Mind taking a look at the current implementation and maybe suggesting fixing changes if you happen to immediately notice easy fixes?

bugs

@underthestars-zhy
Copy link

The textfield is too long.

@austincondiff
Copy link
Collaborator

austincondiff commented Mar 26, 2022

The git clone dialog needs to be narrower than the welcome dialog.

@underthestars-zhy
Copy link

Give this view a title and put Clone existing repository to a HStack with the first textfield

Switched the git clone view folder picking to use NSSavePanel
instead of NSOpenPanel.

NSSavePanel gives us kind of the same flow as Xcode has, as it's also using
NSSavePanel to prompt the target folder for cloning.

The view now consist of two separate modals that pop open, and it may
seem cumbersome, but it now has kind of the same functionality as Xcode.
@Pythonen
Copy link
Member Author

Pythonen commented Mar 26, 2022

Switched a little how the view acts. This is more Xcode-like flow with the repo url and picking the target folder. This way the user now also has an option to clone the repository with some other name

Thoughts?

newview.mov

@Angelk90
Copy link
Contributor

Angelk90 commented Mar 26, 2022

@Pythonen : it works fine even if you put an ssh address, right?

Graphics like this would look very nice.
Schermata 2022-03-26 alle 23 14 45

It would be helpful if it asks you which branch you want to checkout on.
Schermata 2022-03-26 alle 23 10 58

Schermata 2022-03-26 alle 23 16 12

Using the following api, find all reports similar to the search that xcode does.
https://api.github.com/search/repositories?q=code+edit

Info: https://docs.github.com/en/rest/reference/search#search-repositories

@Angelk90
Copy link
Contributor

@lukepistrol : how about adding such a thing too?

Registrazione.schermo.2022-03-28.alle.12.57.04.mov

@Pythonen
Copy link
Member Author

Pythonen commented Mar 28, 2022

it works fine even if you put an ssh address, right?

Yes, git@github.com:CodeEditApp/CodeEdit.git style addresses work aswell as it just uses git pull shell command under the hood

Showing repositories from Github when cloning is cool idea, but for the release 1.0 it feels a bit of a
stretch as it then should be implemented for Gitlab, Bitbucket etc.

@Angelk90
Copy link
Contributor

@Pythonen : I understand, when cloning the report will it allow you to ask which branch you want to checkout on and let you see the cloning progress like Xcode does?

@Pythonen
Copy link
Member Author

when cloning the report will it allow you to ask which branch you want to checkout on and let you see the cloning progress like Xcode does?

In the making 👍

@austincondiff
Copy link
Collaborator

austincondiff commented Mar 28, 2022

I really like this dialog...

Schermata 2022-03-26 alle 23 10 58

Here are a few minor adjustments that need to be made...

  • Put the "Cancel" and "Clone" buttons (in that order), underneath the input and make clone a primary button
  • This dialog should instead be a sheet on top of the welcome screen
  • The application icon should be to the left of the title and text input as shown in the image above
  • The text "Enter a git repository URL:" should be underneath the title and above the text input in the same format as above

@Pythonen
Copy link
Member Author

Pythonen commented Mar 28, 2022

@austincondiff So something along these lines UI-wise?

Näyttökuva 2022-3-28 kello 20 41 59

Repositioning buttons, input and text. Also added app icon to the view
@nanashili
Copy link
Contributor

nanashili commented Mar 30, 2022

Does Xcode allow cloning of personal repos on the welcome screen? @Pythonen

@lukepistrol lukepistrol added the WIP This is work-in-progress label Apr 1, 2022
@Pythonen
Copy link
Member Author

Pythonen commented Apr 1, 2022

Does Xcode allow cloning of personal repos on the welcome screen? @Pythonen

You mean private? AFAIK yes if you have (insert your git hosting site) account added to Xcode.

If you have 'valid' git url in your clipboard when opening the clone
view, it now automatically pastes it to the textfield
@Angelk90
Copy link
Contributor

Angelk90 commented Apr 1, 2022

@Pythonen : Would it be possible to implement the functionality on which branch you want to checkout?

@Pythonen
Copy link
Member Author

Pythonen commented Apr 3, 2022

@Pythonen : Would it be possible to implement the functionality on which branch you want to checkout?

Yes, wip

@lukepistrol lukepistrol changed the title Add functionality for cloning from git in welcome view [WIP] Add functionality for cloning from git in welcome view Apr 5, 2022
@austincondiff
Copy link
Collaborator

@Pythonen Where are we with this PR?

@Pythonen
Copy link
Member Author

@Pythonen Where are we with this PR?

Been pretty busy at work so this has been stalling for a bit now, sorry for that.

AFAIK it's still not possible to open the editor from modules (?) correct me if I'm wrong.
I'd suggest that someone reviews this (requests changes) and merges, so this PR doesn't become too stale in a sense. Then other people can contribute to it aswell.

Your thoughts? @austincondiff

@austincondiff
Copy link
Collaborator

austincondiff commented Apr 12, 2022

@Pythonen totally understand! Let's get this figured out so it doesn't get too stale. I'd hate for your awesome work to go to waste. Make sure you rebase every now and then to prevent this.

@lukepistrol @MarcoCarnevali what do you think? Would this be a good idea to merge what we have here to allow others to finish?

Who is able to help to finish this effort?

@Pythonen Pythonen marked this pull request as ready for review April 13, 2022 09:30
@0xWDG
Copy link
Collaborator

0xWDG commented Apr 13, 2022

@Pythonen Where are we with this PR?

Been pretty busy at work so this has been stalling for a bit now, sorry for that.

AFAIK it's still not possible to open the editor from modules (?) correct me if I'm wrong. I'd suggest that someone reviews this (requests changes) and merges, so this PR doesn't become too stale in a sense. Then other people can contribute to it aswell.

Your thoughts? @austincondiff

i agree, if @MarcoCarnevali approves the pull request, it's better to merge it, and open a issue or so, so that other people can also work on it.

Fixed indentation in WelcomeView and moved the logic of cloning
repository into it's own private function
@austincondiff austincondiff changed the title [WIP] Add functionality for cloning from git in welcome view Add functionality for cloning from git in welcome view Apr 13, 2022
@austincondiff austincondiff merged commit da31956 into CodeEditApp:main Apr 13, 2022
austincondiff pushed a commit that referenced this pull request Apr 18, 2022
* Git Clone: Add basic functionality of cloning repository

Basics of cloning repository implemented. Pressing clone on welcome
view now opens simple window with url input with clone and close buttons

For now it clones the repositories in to your home dir. Error handling
for now is nada and should be implemented in later commits

* Git Clone: Select target folder and clone the repository

Now you can select the folder to which you want to clone the repository.
This defaults to home folder.

Also added check that the repository isn't empty when trying to clone.

* Git Clone: Open cloned folder

Now after we press `clone` button, we firstly clone the specified
repository to given folder. After cloning, we open folder picker for
the user to pick folder to open the editor in. However this could be better if
we straight up open the editor in the cloned folder, rather than giving user an option
to choose the folder in between.

* Git Clone: Add error handling

Added error handling for git related errors e.g. when trying to clone
non existent repository

* Git Clone: Implementation as a module

Changed GitClone to be module as discussed in
#232 (comment)

* Git Clone: Uncomment dependency from Package.swift

* Git Clone: Switch to use NSSavePanel

Switched the git clone view folder picking to use NSSavePanel
instead of NSOpenPanel.

NSSavePanel gives us kind of the same flow as Xcode has, as it's also using
NSSavePanel to prompt the target folder for cloning.

The view now consist of two separate modals that pop open, and it may
seem cumbersome, but it now has kind of the same functionality as Xcode.

* Git Clone: Remove .git only if the url has it.

* Git Clone: Reposition UI

Repositioning buttons, input and text. Also added app icon to the view

* Git Clone: Change clone view to be sheet

Changed git clone view to be sheet instead of normal window. This
is better for UX as you can't click anywhere else than the clone view
until you either cancel or clone the repository

* Git Clone: Validate url and more error handling

Naive Xcode-like check for the url implemented. For now if the url
does not start with certain string, the clone button is disabled, just
like in Xcode.

Also added check for when user decides to press cancel on folder selection
#232 (comment)

* Git Clone: Add automatic pasting

If you have 'valid' git url in your clipboard when opening the clone
view, it now automatically pastes it to the textfield

* GitClone: Fix some force unwrappings and make vars private

* GitClone: Make shellClient constant

* GitClone: Fix indentation and make logic private func

Fixed indentation in WelcomeView and moved the logic of cloning
repository into it's own private function

* GitClone: Add CheckoutBranchModal

Added modal to checkout to other branches after cloning the repository

* GitClone: Make checkout button defaultAction

* GitClone: Add possibility to checkout to remote branches

Showing all branhes to make it possible to checkout to remote
branches as well as local

* GitClone: Make the modal wider

* GitClone: Open checkout branch modal only if there's multiple branches

* GitClone: Refactor extension to separate file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request UI This is UI related WIP This is work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Git clone from the welcome view
8 participants