doc(git-clone): add basic docs

pull/210/head
Brewer, Michael (US - California) 1 year ago
parent 52c8009511
commit cb67c37e98
No known key found for this signature in database
GPG Key ID: 83CCF3ACE4DF618E

@ -50,3 +50,61 @@ data "coder_git_auth" "github" {
id = "github" id = "github"
} }
``` ```
## Github clone with branch name
To github clone a url at a specific branch like `feat/example`
```tf
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
```tf
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/" = {
tree_path = "/tree/"
}
}
}
```
## Gitlab clone with branch name
To gitlab clone a url at a specific branch like `feat/example`
```tf
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
```tf
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/" = {
tree_path = "/-/tree/"
}
}
}
```

@ -104,7 +104,7 @@ describe("git-clone", async () => {
expect(state.outputs.branch_name.value).toEqual("feat/branch"); expect(state.outputs.branch_name.value).toEqual("feat/branch");
}); });
it("gitlab tree url branch_name should match", async () => { it("gitlab url with branch should match", async () => {
const state = await runTerraformApply(import.meta.dir, { const state = await runTerraformApply(import.meta.dir, {
agent_id: "foo", agent_id: "foo",
base_dir: "/tmp", base_dir: "/tmp",
@ -117,7 +117,7 @@ describe("git-clone", async () => {
expect(state.outputs.branch_name.value).toEqual("feat/branch"); expect(state.outputs.branch_name.value).toEqual("feat/branch");
}); });
it("github tree url branch_name should match", async () => { it("github url with branch should match", async () => {
const state = await runTerraformApply(import.meta.dir, { const state = await runTerraformApply(import.meta.dir, {
agent_id: "foo", agent_id: "foo",
base_dir: "/tmp", base_dir: "/tmp",
@ -130,6 +130,25 @@ describe("git-clone", async () => {
expect(state.outputs.branch_name.value).toEqual("feat/branch"); expect(state.outputs.branch_name.value).toEqual("feat/branch");
}); });
it("self-host git url with branch should match", async () => {
const state = await runTerraformApply(import.meta.dir, {
agent_id: "foo",
base_dir: "/tmp",
url: "https://git.example.com/example/project/-/tree/feat/example",
git_providers: `
{
"https://git.example.com/" = {
tree_path = "/-/tree/"
}
}`,
});
expect(state.outputs.repo_dir.value).toEqual("/tmp/project");
const https_url = "https://git.example.com/example/project";
expect(state.outputs.clone_url.value).toEqual(https_url);
expect(state.outputs.web_url.value).toEqual(https_url);
expect(state.outputs.branch_name.value).toEqual("feat/example");
});
it("handle unsupported git provider", async () => { it("handle unsupported git provider", async () => {
const url = "https://git.unknown.com/coder/coder"; const url = "https://git.unknown.com/coder/coder";
const state = await runTerraformApply(import.meta.dir, { const state = await runTerraformApply(import.meta.dir, {

Loading…
Cancel
Save