Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Handle GitLab remotes on non-gitlab hosts/domains #76

Open
perlun opened this issue May 14, 2019 · 2 comments
Open

Handle GitLab remotes on non-gitlab hosts/domains #76

perlun opened this issue May 14, 2019 · 2 comments

Comments

@perlun
Copy link
Contributor

perlun commented May 14, 2019

Thanks for an interesting tool!

For me, the usefulness is a bit limited since our (internal) GitLab server is not named gitlab.foo.bar but instead git.foo.bar, so the heuristics for auto-detecting the GitLab remote does not work

I did the following local tweak which works for me but is rather silly (I have an origin remote which is my personal fork and an upstream remote which is the main repository). If we could find a way to conditionalize this (perhaps with a config parameter or ENV variable), it would be great and increase the usefulness of the tool. Do you have any ideas?

diff --git a/internal/gitutil/gitutil.go b/internal/gitutil/gitutil.go
index c298b1e..c58d867 100644
--- a/internal/gitutil/gitutil.go
+++ b/internal/gitutil/gitutil.go
@@ -193,7 +193,7 @@ func (c *RemoteCollecter) collectTargetByArgs(pInfo *GitLabProjectInfo, project,
 func filterHasGitlabDomain(remoteInfos []*git.RemoteInfo) []*git.RemoteInfo {
 	var gitlabRemotes []*git.RemoteInfo
 	for _, remoteInfo := range remoteInfos {
-		if strings.HasPrefix(remoteInfo.Domain, "gitlab") {
+		if strings.HasPrefix(remoteInfo.Domain, "gitlab") || remoteInfo.Remote == "upstream" {
 			gitlabRemotes = append(gitlabRemotes, remoteInfo)
 		}
 	}
lighttiger2505 added a commit that referenced this issue May 15, 2019
The domain specified in the config file has been added for processing
See #76
@lighttiger2505
Copy link
Owner

Thanks for the contribution. Your opinion is very informative.

I added the ability to virtually define gitlab domain as a solution. You can try this on the following branch.

#77

The virtual gitlab domain feature adds the domain set in the lab command's configuration file to gitlab remote automatic detection.

profiles:
  gitlab.com:
    token: **********************
    default_group: ""
    default_project: ""
    default_assignee_id: 123
  git.foo.bar.jp: # The name is not gitlab
    token: **********************
    default_group: ""
    default_project: ""
    default_assignee_id: 345

For example, git.foo.bar.jp is not gitlab, but lab command detects it.

@perlun
Copy link
Contributor Author

perlun commented May 16, 2019

Thanks @lighttiger2505, much appreciated!

How would this work in the lab browse scenario when no config file exists from beforehand? I think it would be great to be able do something like lab browse --remote upstream or similar, to let it auto-create the config based on the named remote.

What do you think? Just trying to make this feature as easy as possible for people to use.

@perlun perlun changed the title Handle GitLab remotes not named Handle GitLab remotes on non-gitlab domains Sep 5, 2019
@perlun perlun changed the title Handle GitLab remotes on non-gitlab domains Handle GitLab remotes on non-gitlab hosts/domains Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants