Add ability to start from user specified hash.

This feature can be useful for repositories with already established versioning, but
having hundreds of commits which could potentially produce really weird results due
to lack of previous rules on wording.
This commit is contained in:
2021-05-09 19:04:25 +01:00
parent 3b4c00f0ef
commit 1b2292f6cb
6 changed files with 59 additions and 57 deletions
+28
View File
@@ -285,11 +285,23 @@ func (suite *Tests) TestSetup_ListCommits() {
noCommits: true,
wantErr: true,
},
{
name: "List commits starting with certain hash",
fields: fields{
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client",
Force: Force{
Commit: "69fbe2df696f40281b9104ff073d26186cde1024",
},
},
noCommits: false,
wantErr: false,
},
}
for _, tt := range tests {
suite.T().Run(tt.name, func(t *testing.T) {
s := &Setup{
RepositoryName: tt.fields.RepositoryName,
Force: tt.fields.Force,
}
s.Prepare()
listOfCommits, err := s.ListCommits()
@@ -306,6 +318,7 @@ func (suite *Tests) TestSetup_ListCommits() {
func (suite *Tests) TestSetup_CalculateSemver() {
type fields struct {
RepositoryName string
Force Force
}
type wantSemver struct {
Major int
@@ -328,6 +341,20 @@ func (suite *Tests) TestSetup_CalculateSemver() {
Patch: 1,
},
},
{
name: "Test on existing repository, starting with certain hash",
fields: fields{
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client",
Force: Force{
Commit: "69fbe2df696f40281b9104ff073d26186cde1024",
},
},
wantSemver: wantSemver{
Major: 3,
Minor: 0,
Patch: 5,
},
},
{
name: "Test on non-existing repository",
fields: fields{
@@ -344,6 +371,7 @@ func (suite *Tests) TestSetup_CalculateSemver() {
suite.T().Run(tt.name, func(t *testing.T) {
s := &Setup{
RepositoryName: tt.fields.RepositoryName,
Force: tt.fields.Force,
}
s.ReadConfig("../config.yaml")
s.Prepare()