-
-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
34 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,67 +7,67 @@ import ( | |
) | ||
|
||
func TestGitNode_ssh(t *testing.T) { | ||
node, err := NewGitNode("[email protected]:foo/bar.git?ref=main//Taskfile.yml", "", false) | ||
node, err := NewGitNode("[email protected]:foo/bar.git//Taskfile.yml?ref=main", "", false) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "main", node.ref) | ||
assert.Equal(t, "Taskfile.yml", node.path) | ||
assert.Equal(t, "ssh://[email protected]/foo/bar.git?ref=main//Taskfile.yml", node.rawUrl) | ||
assert.Equal(t, "ssh://[email protected]/foo/bar.git//Taskfile.yml?ref=main", node.rawUrl) | ||
assert.Equal(t, "ssh://[email protected]/foo/bar.git", node.URL.String()) | ||
entrypoint, err := node.ResolveEntrypoint("common.yml") | ||
assert.NoError(t, err) | ||
assert.Equal(t, "ssh://[email protected]/foo/bar.git?ref=main//common.yml", entrypoint) | ||
assert.Equal(t, "ssh://[email protected]/foo/bar.git//common.yml?ref=main", entrypoint) | ||
} | ||
|
||
func TestGitNode_sshWithDir(t *testing.T) { | ||
node, err := NewGitNode("[email protected]:foo/bar.git?ref=main//directory/Taskfile.yml", "", false) | ||
node, err := NewGitNode("[email protected]:foo/bar.git//directory/Taskfile.yml?ref=main", "", false) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "main", node.ref) | ||
assert.Equal(t, "directory/Taskfile.yml", node.path) | ||
assert.Equal(t, "ssh://[email protected]/foo/bar.git?ref=main//directory/Taskfile.yml", node.rawUrl) | ||
assert.Equal(t, "ssh://[email protected]/foo/bar.git//directory/Taskfile.yml?ref=main", node.rawUrl) | ||
assert.Equal(t, "ssh://[email protected]/foo/bar.git", node.URL.String()) | ||
entrypoint, err := node.ResolveEntrypoint("common.yml") | ||
assert.NoError(t, err) | ||
assert.Equal(t, "ssh://[email protected]/foo/bar.git?ref=main//directory/common.yml", entrypoint) | ||
assert.Equal(t, "ssh://[email protected]/foo/bar.git//directory/common.yml?ref=main", entrypoint) | ||
} | ||
|
||
func TestGitNode_https(t *testing.T) { | ||
node, err := NewGitNode("https://github.com/foo/bar.git?ref=main//Taskfile.yml", "", false) | ||
node, err := NewGitNode("https://github.com/foo/bar.git//Taskfile.yml?ref=main", "", false) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "main", node.ref) | ||
assert.Equal(t, "Taskfile.yml", node.path) | ||
assert.Equal(t, "https://github.com/foo/bar.git?ref=main//Taskfile.yml", node.rawUrl) | ||
assert.Equal(t, "https://github.com/foo/bar.git//Taskfile.yml?ref=main", node.rawUrl) | ||
assert.Equal(t, "https://github.com/foo/bar.git", node.URL.String()) | ||
entrypoint, err := node.ResolveEntrypoint("common.yml") | ||
assert.NoError(t, err) | ||
assert.Equal(t, "https://github.com/foo/bar.git?ref=main//common.yml", entrypoint) | ||
assert.Equal(t, "https://github.com/foo/bar.git//common.yml?ref=main", entrypoint) | ||
} | ||
|
||
func TestGitNode_httpsWithDir(t *testing.T) { | ||
node, err := NewGitNode("https://github.com/foo/bar.git?ref=main//directory/Taskfile.yml", "", false) | ||
node, err := NewGitNode("https://github.com/foo/bar.git//directory/Taskfile.yml?ref=main", "", false) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "main", node.ref) | ||
assert.Equal(t, "directory/Taskfile.yml", node.path) | ||
assert.Equal(t, "https://github.com/foo/bar.git?ref=main//directory/Taskfile.yml", node.rawUrl) | ||
assert.Equal(t, "https://github.com/foo/bar.git//directory/Taskfile.yml?ref=main", node.rawUrl) | ||
assert.Equal(t, "https://github.com/foo/bar.git", node.URL.String()) | ||
entrypoint, err := node.ResolveEntrypoint("common.yml") | ||
assert.NoError(t, err) | ||
assert.Equal(t, "https://github.com/foo/bar.git?ref=main//directory/common.yml", entrypoint) | ||
assert.Equal(t, "https://github.com/foo/bar.git//directory/common.yml?ref=main", entrypoint) | ||
} | ||
|
||
func TestGitNode_FilenameAndDir(t *testing.T) { | ||
node, err := NewGitNode("https://github.com/foo/bar.git?ref=main//directory/Taskfile.yml", "", false) | ||
node, err := NewGitNode("https://github.com/foo/bar.git//directory/Taskfile.yml?ref=main", "", false) | ||
assert.NoError(t, err) | ||
filename, dir := node.FilenameAndLastDir() | ||
assert.Equal(t, "Taskfile.yml", filename) | ||
assert.Equal(t, "directory", dir) | ||
|
||
node, err = NewGitNode("https://github.com/foo/bar.git?ref=main//Taskfile.yml", "", false) | ||
node, err = NewGitNode("https://github.com/foo/bar.git//Taskfile.yml?ref=main", "", false) | ||
assert.NoError(t, err) | ||
filename, dir = node.FilenameAndLastDir() | ||
assert.Equal(t, "Taskfile.yml", filename) | ||
assert.Equal(t, ".", dir) | ||
|
||
node, err = NewGitNode("https://github.com/foo/bar.git?ref=main//multiple/directory/Taskfile.yml", "", false) | ||
node, err = NewGitNode("https://github.com/foo/bar.git//multiple/directory/Taskfile.yml?ref=main", "", false) | ||
assert.NoError(t, err) | ||
filename, dir = node.FilenameAndLastDir() | ||
assert.Equal(t, "Taskfile.yml", filename) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,10 +64,11 @@ includes: | |
|
||
## Git nodes | ||
|
||
You can also include a Taskfile from a Git node. We currently support ssh-style and http / https addresses like `[email protected]/foo/bar?ref=v1//Taskfiles.yml` and `https://example.com/foo/bar.git?ref=v1//Taskfiles.yml`. | ||
You can also include a Taskfile from a Git node. We currently support ssh-style and http / https addresses like `[email protected]/foo/bar.git//Taskfiles.yml?ref=v1` and `https://example.com/foo/bar.git//Taskfiles.yml?ref=v1`. | ||
|
||
You need to follow this pattern : `<baseUrl>.git?ref=<ref>//<path>`. | ||
The `ref` parameter can be a branch name or a tag, and the `path` is the path to the Taskfile in the repository. | ||
You need to follow this pattern : `<baseUrl>.git//<path>?ref=<ref>`. | ||
The `ref` parameter, optional, can be a branch name or a tag, if not provided it'll pick up the default branch. | ||
The `path` is the path to the Taskfile in the repository. | ||
|
||
If you want to use the SSH protocol, you need to make sure that your ssh-agent has your private ssh keys added so that they can be used during authentication. | ||
|
||
|