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

Organized Repos End with .git #83

Closed
alexlafroscia opened this issue May 10, 2021 · 3 comments
Closed

Organized Repos End with .git #83

alexlafroscia opened this issue May 10, 2021 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@alexlafroscia
Copy link

Hey! I love the idea of the organize command to clean up my messy ~/Code folder.

I ran it this morning and have found that all of the moved directories now end in .git. Here's an example of the directory with all my work repositories in it:

Repo List

drwxr-xr-x - alafroscia  2 Oct  2020 AIExpedition.git
drwxr-xr-x - alafroscia  4 Dec  2019 boxes-interview-app.git
drwxr-xr-x - alafroscia 10 Jan  2020 builder.git
drwxr-xr-x - alafroscia 11 Feb  2020 cartridge_hooks.git
drwxr-xr-x - alafroscia  9 Mar 14:21 dependabot-clubhouse-actions.git
drwxr-xr-x - alafroscia 11 Jan 08:53 docker-images.git
drwxr-xr-x - alafroscia 20 May  2020 ember-bar-chart.git
drwxr-xr-x - alafroscia  5 Dec  2019 ember-cli-deploy-github-deployment-status.git
drwxr-xr-x - alafroscia 24 Jan  2020 ember-cli-deploy-gitlab-scm-data-generator.git
drwxr-xr-x - alafroscia 23 Oct  2019 ember-cli-mirage.git
drwxr-xr-x - alafroscia  2 Feb 17:09 ember-cli-sentry.git
drwxr-xr-x - alafroscia  1 Mar 13:57 ember-data-json-api-bulk-ext.git
drwxr-xr-x - alafroscia  4 Sep  2019 ember-examples.git
drwxr-xr-x - alafroscia 20 Sep  2019 ember-pop-over.git
drwxr-xr-x - alafroscia 25 Jan  2020 ember-radio-button.git
drwxr-xr-x - alafroscia 27 Apr  2020 eslint-plugin-no-wildcard-postmessage.git
drwxr-xr-x - alafroscia 11 Mar 16:02 fluid-docs-investigation.git
drwxr-xr-x - alafroscia 13 Nov  2019 fluid-tailwind-playground.git
drwxr-xr-x - alafroscia 18 Sep  2019 fluid-wc.git
drwxr-xr-x - alafroscia  8 May 13:22 front-end.git
drwxr-xr-x - alafroscia  8 Apr  2020 fullstack-interview-stats-table.git
drwxr-xr-x - alafroscia 11 Feb  2020 gitd
drwxr-xr-x - alafroscia 11 Feb  2020 gitd.git
drwxr-xr-x - alafroscia  6 May 16:34 lint-config.git
drwxr-xr-x - alafroscia 28 Apr 16:15 movableink.git
drwxr-xr-x - alafroscia 25 Feb 16:13 page-objects.git
drwxr-xr-x - alafroscia 29 Jun  2020 provisioning
drwxr-xr-x - alafroscia  6 Sep  2019 rfcs.git
drwxr-xr-x - alafroscia 28 Oct  2020 studio-app-tools.git
drwxr-xr-x - alafroscia 28 Oct  2020 studio-apps.git
drwxr-xr-x - alafroscia 29 Mar 15:14 studio-framework.git
drwxr-xr-x - alafroscia 28 Oct  2020 studio-package-proxy.git
drwxr-xr-x - alafroscia 20 Jan 11:53 studio-packaging-service.git
drwxr-xr-x - alafroscia  1 Apr 10:02 tailwind-config.git
drwxr-xr-x - alafroscia 14 Apr 15:18 template-lint-plugin.git
drwxr-xr-x - alafroscia 19 Nov  2020 terraform.git

Is this intentional? At least in my case, this was unexpected. I ran the dry run first but I guess didn't notice that .git was going to be added to all of these.

@Byron Byron added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels May 12, 2021
@Byron
Copy link
Owner

Byron commented May 12, 2021

That's a great point! I think you won't be the only one surprised by this. What's happening here is expected as organize will build a path based on the remote url which in your case seems to be https://host/name/repo.git, with .git being a convention that GitHub and GitLab apply when handing out clone URLs.

I never noticed this as I always just clone from the URL visible in the browser - it works just as well even though this feature isn't really advertised. So for me, remote URLs look like https://host/name/repo yielding the paths I expect.

Since this is a valuable improvement to make, here is where such a transformation to remove '.git' extensions could be added:

let destination = canonicalized_destination
.join(
url.host
.as_ref()
.ok_or_else(|| anyhow::Error::msg(format!("Remote URLs must have host names: {}", url)))?,
)
.join(to_relative(git_url::expand_path(None, url.path.as_bstr())?));

(in line 162). However, that should only be done if the repository has a working tree. Bare repositories are usually denoted by keeping their .git suffix.

@Byron
Copy link
Owner

Byron commented May 12, 2021

I couldn't help myself but to 'warm up' by implementing the improvement, so this feature is now available in the latest main.

@alexlafroscia
Copy link
Author

Awesome, thank you both for the context on why this happens and the fix itself! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants