8000 feat(git-clone): add support for tree github or gitlab clone url by michaelbrewer · Pull Request #210 · coder/modules · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

feat(git-clone): add support for tree github or gitlab clone url #210

Merged
merged 23 commits into from
Apr 17, 2024

Conversation

michaelbrewer
Copy link
Contributor
@michaelbrewer michaelbrewer commented Apr 1, 2024

Allow for git clone urls to include branch names like for gitlab / github urls with "tree".

Changes

  • Backwards compatibility tests
  • Support gitlab tree urls (https://github.com/org.name/repo-name.fun/tree/feat/branch)
  • Support github tree urls (https://gitlab.com/group/sub-group/sub-sub-group/repo-name.fun/-/tree/feat/branch)
  • Support for self-hosted github / gitlab urls
  • Trim off any query strings in the url like: ?ref_type=heads
  • Trim off any fragments in the url like: #example
  • Add support for web_url in the output, for both HTTP and SSH git clone urls
  • Add basic docs
  • Add more complete example for a "Open in Coder" workflow

Github clone with branch name

To github clone a url at a specific branch like feat/example

module "git-clone" {
  source   = "registry.coder.com/modules/git-clone/coder"
  version  = "1.0.11"
  agent_id = coder_agent.example.id
  url      = "https://github.com/coder/coder/tree/feat/example"
}

Self host github

module "git-clone" {
  source   = "registry.coder.com/modules/git-clone/coder"
  version  = "1.0.11"
  agent_id = coder_agent.example.id
  url      = "https://github.example.com/coder/coder/tree/feat/example"
  git_providers = {
    "https://github.example.com/" = {
      provider = "github"
    }
  }
}

Gitlab clone with branch name

To gitlab clone a url at a specific branch like feat/example

module "git-clone" {
  source   = "registry.coder.com/modules/git-clone/coder"
  version  = "1.0.11"
  agent_id = coder_agent.example.id
  url      = "https://gitlab.com/coder/coder/-/tree/feat/example"
}

Self host gitlab

module "git-clone" {
  source   = "registry.coder.com/modules/git-clone/coder"
  version  = "1.0.11"
  agent_id = coder_agent.example.id
  url      = "https://gitlab.example.com/coder/coder/-/tree/feat/example"
  git_providers = {
    "https://gitlab.example.com/" = {
      provider = "gitlab"
    }
  }
}

closes #212

@michaelbrewer michaelbrewer marked this pull request as draft April 1, 2024 01:25
@michaelbrewer michaelbrewer marked this pull request as ready for review April 2, 2024 07:02
@michaelbrewer
Copy link
Contributor Author

@matifali - i can change the tests that does real clones to a different repo. Or remove them. If this looks good, i can add some docs with examples.

Bitbucket urls are a bit strange, so i will need to think about a clean way.

@matifali matifali requested review from kylecarbs and mafredri April 4, 2024 08:25
@matifali
Copy link
Member
matifali commented Apr 5, 2024

@michaelbrewer Thank you for this excellent contribution. This PR will significantly enhance the module's utility and allow users to use coder in many new ways. I won't be able to look at the specifics and have requested @mafredri and @code-asher to review the PR.

@matifali matifali requested a review from code-asher April 5, 2024 13:09
Copy link
Member
@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

This is a really cool feature, nice work. And thanks for adding all those tests.

@michaelbrewer michaelbrewer changed the title feat(git-clone): add support for tree git clone url feat(git-clone): add support for tree github or gitlab clone url Apr 6, 2024
@michaelbrewer michaelbrewer requested a review from mafredri April 6, 2024 20:18
@michaelbrewer
Copy link
Contributor Author

I have made some changes to allow for more flexibility.

Copy link
Member
@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

I think we just need to update some references in the docs, then this looks good to me.

michaelbrewer and others added 4 commits April 16, 2024 14:36
Co-authored-by: Asher <ash@coder.com>
Co-authored-by: Asher <ash@coder.com>
Co-authored-by: Asher <ash@coder.com>
@michaelbrewer
Copy link
Contributor Author

@code-asher - feel free to use different urls for the integration tests. I will leave my repos up so long :)

Copy link
Member
@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

@code-asher
Copy link
Member

@code-asher - feel free to use different urls for the integration tests. I will leave my repos up so long :)

Ohh yeah good point, we should probably use some Coder repos at some point...easy enough for GitHub but unfortunately I think we do not have anything on Gitlab at the moment.

@matifali
Copy link
Member
matifali commented Apr 17, 2024

@code-asher, could you please merge this if there are no more suggestions?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(git-clone): add support for tree git clone url
4 participants
0