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

Set gitHostFactory for gitlab self hosted instances #4775

Merged
merged 5 commits into from
Aug 29, 2024

Conversation

fgLouro
Copy link
Contributor

@fgLouro fgLouro commented Aug 27, 2024

☕️ Reasoning

The DefaultGitHostFactory class assumes that gitlab domain is always gitlab.com, which is not correct for self hosted instances of gitlab, and leads to branch link buttons to be unusable.

🧢 Changes

  • Adds resource to RepoInfo type to be used for adding the correct baseUrl
  • Checks resource for gitlab subdomain to initialize the gitHostFactory with a Gitlab class

🎫 Affected issues

Fixes: #4558 (comment)

Things to consider

Self hosted instance might not have gitlab in their subdomain, which will result in the same issue.

Copy link

vercel bot commented Aug 27, 2024

@fgLouro is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@@ -8,7 +8,8 @@ describe.concurrent('GitHubBranch', () => {
const repo = {
source: 'github.com',
name: 'test-repo',
owner: 'test-owner'
owner: 'test-owner',
resource: 'test-resource'
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not add these unless necessary for the test to pass?

@@ -4,20 +4,22 @@ export type RepoInfo = {
source: string;
name: string;
owner: string;
resource: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

And make this optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't it be misleading to use an optional attribute for the resource?

The gitUrlParse function seems to always return a resource attribute when the url is valid, even if it's an empty 'resource' it's not undefined.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I forgot what it represents, and sorry for the back and forth here. I think.. we should only have one field for url, instead of calling it source and resource. If you agree, would you mind creating a type and replacing the one we borrow from the parsing lib?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Back and forth is how good software is made 😄

You mean removing the resource and source from the RepoInfo type and have only a url attribute which will be the value of resource (the full url)?

I think the source is only used in DefaultGitHostFactory class, so should be easy to replace it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, exactly! I would probably go with domain over url since it is likely to have additional things like scheme, path, etc. Also, my previous message was probably confusing because I forgot we have our own RepoInfo type, I thought we were using the one returned from git-url-parse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mtsgrd Done!

Removed all references of source and resource in favour or using domain.

Copy link
Contributor

@mtsgrd mtsgrd left a comment

Choose a reason for hiding this comment

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

A'ight, awesome. Let's ship it!

@mtsgrd mtsgrd enabled auto-merge (rebase) August 29, 2024 15:23
@mtsgrd mtsgrd merged commit 9234939 into gitbutlerapp:master Aug 29, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Branch button no longer opens branch in browser
3 participants