-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create annotated tag and list project tags optimised (#23)
* refactor: get latest project version using native version sort and filter * fix: create annotated tags rather than lightweight * fix: up git-module to support annotated tags and efficient tag filter and sorting * feat: add envvars and restructure * test: add unit tests to tag component * fix: minor cleanup * refactor: introduce git client interfaces
- Loading branch information
Showing
36 changed files
with
1,002 additions
and
410 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package main | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
ctx "github.com/sermojohn/gitmono" | ||
) | ||
|
||
func Test_loadEnvVars(t *testing.T) { | ||
t.Parallel() | ||
|
||
type args struct { | ||
loaderFunc func(string) (string, bool) | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want *ctx.EnvVars | ||
}{ | ||
{ | ||
name: "no vars", | ||
args: args{ | ||
loaderFunc: func(s string) (string, bool) { | ||
return "", false | ||
}, | ||
}, | ||
want: &ctx.EnvVars{}, | ||
}, | ||
{ | ||
name: "git committer vars", | ||
args: args{ | ||
loaderFunc: func(s string) (string, bool) { | ||
if s == "GIT_COMMITTER_NAME" { | ||
return "alice", true | ||
} | ||
if s == "GIT_COMMITTER_EMAIL" { | ||
return "alice@example.com", true | ||
} | ||
return "", false | ||
}, | ||
}, | ||
want: &ctx.EnvVars{ | ||
CommitterName: "alice", | ||
CommitterEmail: "alice@example.com", | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := loadEnvVars(tt.args.loaderFunc); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("loadEnvVars() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package mock | ||
|
||
import "github.com/gogs/git-module" | ||
|
||
type GitTagger struct { | ||
TagsOutput []string | ||
TagsError error | ||
TagsInputs []*TagsInput | ||
CreateTagError error | ||
CreateTagInputs []*CreateTagInput | ||
} | ||
|
||
func (gt *GitTagger) Tags(opts ...git.TagsOptions) ([]string, error) { | ||
if gt.TagsError != nil { | ||
return nil, gt.TagsError | ||
} | ||
gt.TagsInputs = append(gt.TagsInputs, &TagsInput{Opts: opts}) | ||
return gt.TagsOutput, nil | ||
} | ||
|
||
func (gt *GitTagger) CreateTag(name, rev string, opts ...git.CreateTagOptions) error { | ||
if gt.CreateTagError != nil { | ||
return gt.CreateTagError | ||
} | ||
gt.CreateTagInputs = append(gt.CreateTagInputs, &CreateTagInput{ | ||
Name: name, | ||
Rev: rev, | ||
Opts: opts, | ||
}) | ||
return nil | ||
} | ||
|
||
type TagsInput struct { | ||
Opts []git.TagsOptions | ||
} | ||
|
||
type CreateTagInput struct { | ||
Name string | ||
Rev string | ||
Opts []git.CreateTagOptions | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package mock | ||
|
||
import "github.com/sermojohn/gitmono" | ||
|
||
type Tagger struct { | ||
ListProjectVersionTagsOutput []string | ||
ListProjectVersionTagsError error | ||
CreateTagError error | ||
} | ||
|
||
func (t *Tagger) ListProjectVersionTags() ([]string, error) { | ||
if t.ListProjectVersionTagsError != nil { | ||
return nil, t.ListProjectVersionTagsError | ||
} | ||
|
||
return t.ListProjectVersionTagsOutput, nil | ||
} | ||
|
||
func (t *Tagger) CreateTag(versionedCommit *gitmono.VersionedCommit) error { | ||
return t.CreateTagError | ||
} |
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
Oops, something went wrong.