Add preference flag_defaults.remote, refactor #466

Merged
6543 merged 13 commits from noerw/tea:fix-458 into master 2022-03-28 23:34:14 +00:00
Member

This is a refactor of the code last touched in #458, making the control flow less backwards.

Additionally, this adds a preference preferences.flag_defaults.remote that allows to skip this heuristic and set a custom fixed default value for the --remote flag.
I'm not sure this is actually needed, I can revert that commit.

This is a refactor of the code last touched in #458, making the control flow less backwards. Additionally, this adds a preference `preferences.flag_defaults.remote` that allows to skip this heuristic and set a custom fixed default value for the `--remote` flag. I'm not sure this is actually needed, I can revert that commit.
noerw added 3 commits 2022-03-10 12:23:10 +00:00
add preferences.default_origin
if set, this skips the main branch based remote selection
All checks were successful
continuous-integration/drone/pr Build is passing
e53c615164
noerw added the
kind
enhancement
label 2022-03-11 07:40:55 +00:00
noerw added this to the v0.9.0 milestone 2022-03-11 07:41:00 +00:00
noerw added 1 commit 2022-03-11 07:54:55 +00:00
Re-revert #458 (kind of)
When no main/master/trunk branch is present, fallback the remote
to origin or upstream. The previous PR used this fallback as default
case, which is was bothered me.
All checks were successful
continuous-integration/drone/pr Build is passing
03bd42190f
noerw changed title from Add preference `default_remote` to skip branch based login selection to Fix remote selection priority, add `default_remote` preference 2022-03-11 08:02:00 +00:00
noerw force-pushed fix-458 from 03bd42190f to 366aea4a9d 2022-03-11 08:03:30 +00:00 Compare
noerw added 1 commit 2022-03-11 08:03:47 +00:00
Merge branch 'master' into fix-458
Some checks failed
continuous-integration/drone/pr Build is failing
4ea7bd267d
noerw added the
kind/bug
label 2022-03-11 08:05:22 +00:00
6543 added 1 commit 2022-03-13 00:55:07 +00:00
Merge branch 'master' into fix-458
All checks were successful
continuous-integration/drone/pr Build is passing
4766c63aba
6543 approved these changes 2022-03-13 00:58:04 +00:00
6543 left a comment
Owner

agree this is more granular

agree this is more granular
noerw added 1 commit 2022-03-13 08:15:27 +00:00
Merge branch 'master' into fix-458
All checks were successful
continuous-integration/drone/pr Build is passing
b0e7538914
noerw added 1 commit 2022-03-16 20:19:52 +00:00
rename config field
preferences.default_remote -> preferences.flag_defaults.remote
All checks were successful
continuous-integration/drone/pr Build is passing
d91ffe401a
noerw added 1 commit 2022-03-16 20:21:04 +00:00
fixup! rename config field
All checks were successful
continuous-integration/drone/pr Build is passing
389d96ae71
Contributor

I do like the default_remote change, but #458 does not prefer origin over main branch, actually it is kind of "fallback" when main is not present, you just wrote it in different way.

I do like the `default_remote` change, but #458 does not prefer `origin` over `main` branch, actually it is kind of "fallback" when `main` is not present, you just wrote it in different way.
Author
Member

@arkamar Damn, I just realized that you're totally right and the priority is no different. Should make sure I'm properly awake when reviewing things next time, sorry for the noise!
But I guess this PR makes the code section more readable / less backwards, so mistakes like these are less likely ?

@arkamar Damn, I just realized that you're totally right and the priority is no different. Should make sure I'm properly awake when reviewing things next time, sorry for the noise! But I guess this PR makes the code section more readable / less backwards, so mistakes like these are less likely ?
noerw added
kind
refactor
and removed
kind/bug
labels 2022-03-18 11:29:15 +00:00
noerw changed title from Fix remote selection priority, add `default_remote` preference to Add preference `flag_defaults.remote`, refactor 2022-03-18 11:29:47 +00:00
arkamar requested changes 2022-03-18 11:44:03 +00:00
@ -162,4 +167,1 @@
if len(gitConfig.Remotes) >= 1 && len(remoteValue) == 0 {
for remote := range gitConfig.Remotes {
remoteValue = remote
}
Contributor

You made tea by default unusable for repositories with just one remote by this change. This was here to selecet at least some remote if availeble but you moved it to a part for more than one remotes. In case of one remote tea pr prints this.

2022/03/18 12:42:17 Remote '' not found in this Git repository
You made `tea` by default unusable for repositories with just one remote by this change. This was here to selecet at least some remote if availeble but you moved it to a part for more than one remotes. In case of one remote `tea pr` prints this. ``` 2022/03/18 12:42:17 Remote '' not found in this Git repository ```
Author
Member

fixed

fixed
noerw marked this conversation as resolved
noerw added 1 commit 2022-03-18 11:53:50 +00:00
fix logic for len(remotes)==1
All checks were successful
continuous-integration/drone/pr Build is passing
82f89c271c
arkamar approved these changes 2022-03-18 12:18:30 +00:00
@ -184,0 +188,4 @@
// make sure a remote is selected
if len(remoteValue) == 0 {
for remote := range gitConfig.Remotes {
remoteValue = remote
Contributor

Maybe we can break after the first remote, there is no need to iterate through all of them.

Maybe we can break after the first remote, there is no need to iterate through all of them.
Author
Member

this is breaking though for little benefit in 99% of cases

this is breaking though for little benefit in 99% of cases
6543 marked this conversation as resolved
6543 added 2 commits 2022-03-28 21:52:23 +00:00
Merge branch 'master' into fix-458
Some checks failed
continuous-integration/drone/pr Build is failing
149b00e0e5
6543 approved these changes 2022-03-28 21:53:36 +00:00
zeripath added 1 commit 2022-03-28 23:18:54 +00:00
Merge branch 'master' into fix-458
All checks were successful
continuous-integration/drone/pr Build is passing
1d25f40e65
zeripath approved these changes 2022-03-28 23:22:36 +00:00
6543 merged commit 6663d9f19b into master 2022-03-28 23:34:14 +00:00
6543 deleted branch fix-458 2022-03-28 23:34:14 +00:00
Sign in to join this conversation.
No description provided.