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

Make sure remote is always called "origin" when cloning git repo #2996

Merged
merged 1 commit into from
Mar 1, 2023

Conversation

mkurz
Copy link
Contributor

@mkurz mkurz commented Feb 28, 2023

While working on #2995 I ran into a problem that prevented me from running scala steward locally on my machine.
That's because in my ~/.gitconfig I configured that the default remote of a freshly cloned git repo should always be called upstream:

[clone]
        defaultRemoteName = upstream

However, if you grep through the scala-steward source code, you will see that scala-stewared heavily and basically everywhere and always relies on the remote's name to be origin.

So this pull requests make sure that when scala-steward clones a git repository the name of the remote is always called "origin" by overriding global git config (user) setting directly at the git-clone command.
With this fix I was able to run scala-steward locally, without it it always failed (or better: the git commands scala-steward calls failed in their sub-processes).

BTW, I had the same issue already with pacman (package manager for arch linux), where I applied the same fix:

I am 100% sure this fix is correct (since I tested it locally 😉). Thanks!

@codecov
Copy link

codecov bot commented Mar 1, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change

Comparison is base (f8bc50b) 90.88% compared to head (1a5e30d) 90.88%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2996   +/-   ##
=======================================
  Coverage   90.88%   90.88%           
=======================================
  Files         160      160           
  Lines        3314     3314           
  Branches      306      306           
=======================================
  Hits         3012     3012           
  Misses        302      302           
Impacted Files Coverage Δ
...n/scala/org/scalasteward/core/git/FileGitAlg.scala 98.63% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@alejandrohdezma
Copy link
Member

Hey @mkurz! From what I see in git-glone docs the suggested way to override the global configuration is using the --origin flag. Would you mind changing it to that?

@mkurz
Copy link
Contributor Author

mkurz commented Mar 1, 2023

@alejandrohdezma I explained the reason why I use -c clone.defaultRemoteName=... and not --origin in https://gitlab.archlinux.org/pacman/pacman/-/merge_requests/19 already:

You might think why use -c clone.defaultRemoteName=... and not -o ...? That's because -o is not allowed together with --bare (which is implied when using --mirror). This is strange and makes no sense, that's why upcoming (not yet released) git v2.38.2 will lift this restriction:

So --clone doesn't play well with --bare for git versions <2.38.2. I know that in the scala-steward source code neither the --bare nor the --mirror flags are used, however in case after this PR a bare clone command gets added to scala steward, for whatever reason, scala-steward would break for people using an older git version (Ubuntu 18.04 or 20.04 pretty sure still have an older git version installed).

Further I wrote in the pacman issue:

I think it's reasonable to just use the -c ... config for now, it's equivalent anyway and setting it on the command line will overrule any global settings (precedence are listed in the git message here)

So I think it's safer for now to stick with -c clone.defaultRemoteName=...

@alejandrohdezma alejandrohdezma merged commit 9367739 into scala-steward-org:main Mar 1, 2023
@mkurz mkurz deleted the git-clone-origin branch March 1, 2023 10:11
@fthomas fthomas added this to the 0.23.0 milestone Mar 1, 2023
@fthomas fthomas added the bug Something isn't working label Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants