mirror of
https://github.com/lukaszraczylo/semver-generator.git
synced 2026-06-21 01:51:26 +00:00
fixup! Update documentation.
This commit is contained in:
+9
-10
@@ -26,21 +26,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
err error
|
|
||||||
repo *Setup
|
repo *Setup
|
||||||
PKG_VERSION string
|
PKG_VERSION string
|
||||||
)
|
)
|
||||||
|
|
||||||
// Setup represents the application setup
|
// Setup represents the application setup
|
||||||
type Setup struct {
|
type Setup struct {
|
||||||
RepositoryName string
|
RepositoryName string
|
||||||
RepositoryBranch string
|
RepositoryBranch string
|
||||||
LocalConfigFile string
|
LocalConfigFile string
|
||||||
Generate bool
|
Generate bool
|
||||||
UseLocal bool
|
UseLocal bool
|
||||||
GitRepo utils.GitRepository
|
GitRepo utils.GitRepository
|
||||||
Config *utils.Config
|
Config *utils.Config
|
||||||
Semver utils.SemVer
|
Semver utils.SemVer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the fuzzy search function in the utils package
|
// Initialize the fuzzy search function in the utils package
|
||||||
@@ -74,7 +73,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
utils.Info("semver-gen", map[string]interface{}{
|
utils.Info("semver-gen", map[string]interface{}{
|
||||||
"version": PKG_VERSION,
|
"version": PKG_VERSION,
|
||||||
"outdated": outdatedMsg,
|
"outdated": outdatedMsg,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -382,10 +382,10 @@ func (suite *Tests) Test_parseExistingSemver() {
|
|||||||
|
|
||||||
func (suite *Tests) TestSetup_ListCommits() {
|
func (suite *Tests) TestSetup_ListCommits() {
|
||||||
type fields struct {
|
type fields struct {
|
||||||
RepositoryName string
|
RepositoryName string
|
||||||
RepositoryBranch string
|
RepositoryBranch string
|
||||||
LocalConfigFile string
|
LocalConfigFile string
|
||||||
GitRepo utils.GitRepository
|
GitRepo utils.GitRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|||||||
+13
-13
@@ -29,14 +29,14 @@ type TagDetails struct {
|
|||||||
|
|
||||||
// GitRepository represents a git repository
|
// GitRepository represents a git repository
|
||||||
type GitRepository struct {
|
type GitRepository struct {
|
||||||
Handler *git.Repository
|
Handler *git.Repository
|
||||||
Name string
|
Name string
|
||||||
Branch string
|
Branch string
|
||||||
LocalPath string
|
LocalPath string
|
||||||
UseLocal bool
|
UseLocal bool
|
||||||
Commits []CommitDetails
|
Commits []CommitDetails
|
||||||
Tags []TagDetails
|
Tags []TagDetails
|
||||||
StartCommit string
|
StartCommit string
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrepareRepository prepares the git repository for use
|
// PrepareRepository prepares the git repository for use
|
||||||
@@ -48,7 +48,7 @@ func PrepareRepository(repo *GitRepository) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
Error("Unable to parse repository URL", map[string]interface{}{
|
Error("Unable to parse repository URL", map[string]interface{}{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
"url": repo.Name,
|
"url": repo.Name,
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ func PrepareRepository(repo *GitRepository) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
Error("Unable to clone repository", map[string]interface{}{
|
Error("Unable to clone repository", map[string]interface{}{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
"url": repo.Name,
|
"url": repo.Name,
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ func PrepareRepository(repo *GitRepository) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
Error("Unable to open local repository", map[string]interface{}{
|
Error("Unable to open local repository", map[string]interface{}{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
"path": repo.LocalPath,
|
"path": repo.LocalPath,
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ func ListCommits(repo *GitRepository) ([]CommitDetails, error) {
|
|||||||
if cmt.Hash == repo.StartCommit {
|
if cmt.Hash == repo.StartCommit {
|
||||||
Debug("Found commit match", map[string]interface{}{
|
Debug("Found commit match", map[string]interface{}{
|
||||||
"commit": cmt.Hash,
|
"commit": cmt.Hash,
|
||||||
"index": commitId,
|
"index": commitId,
|
||||||
})
|
})
|
||||||
repo.Commits = tmpResults[commitId:]
|
repo.Commits = tmpResults[commitId:]
|
||||||
break
|
break
|
||||||
@@ -170,7 +170,7 @@ func ListExistingTags(repo *GitRepository) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Debug("Found tag", map[string]interface{}{
|
Debug("Found tag", map[string]interface{}{
|
||||||
"tag": ref.Name().Short(),
|
"tag": ref.Name().Short(),
|
||||||
"hash": ref.Hash().String(),
|
"hash": ref.Hash().String(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -71,7 +71,7 @@ func UpdatePackage() bool {
|
|||||||
err = g.Download(output, downloadedBinaryPath)
|
err = g.Download(output, downloadedBinaryPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Error("Unable to download binary", map[string]interface{}{
|
Error("Unable to download binary", map[string]interface{}{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
"binaryPath": downloadedBinaryPath,
|
"binaryPath": downloadedBinaryPath,
|
||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInitLogger(t *testing.T) {
|
func TestInitLogger(t *testing.T) {
|
||||||
// Test with debug mode enabled
|
// Test with debug mode enabled
|
||||||
logger := InitLogger(true)
|
logger := InitLogger(true)
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ func CalculateSemver(
|
|||||||
for _, tagHash := range tags {
|
for _, tagHash := range tags {
|
||||||
if commit.Hash == tagHash.Hash {
|
if commit.Hash == tagHash.Hash {
|
||||||
Debug("Found existing tag", map[string]interface{}{
|
Debug("Found existing tag", map[string]interface{}{
|
||||||
"tag": tagHash.Name,
|
"tag": tagHash.Name,
|
||||||
"commit": strings.TrimSuffix(commit.Message, "\n"),
|
"commit": strings.TrimSuffix(commit.Message, "\n"),
|
||||||
})
|
})
|
||||||
semver = ParseExistingSemver(tagHash.Name, semver)
|
semver = ParseExistingSemver(tagHash.Name, semver)
|
||||||
|
|||||||
@@ -77,10 +77,10 @@ func TestCalculateSemver(t *testing.T) {
|
|||||||
respectExisting: true,
|
respectExisting: true,
|
||||||
strictMode: false,
|
strictMode: false,
|
||||||
want: SemVer{
|
want: SemVer{
|
||||||
Major: 2,
|
Major: 2,
|
||||||
Minor: 0,
|
Minor: 0,
|
||||||
Patch: 1, // Initial tag 2.0.0 + one patch increment
|
Patch: 1, // Initial tag 2.0.0 + one patch increment
|
||||||
Release: 1,
|
Release: 1,
|
||||||
EnableReleaseCandidate: true,
|
EnableReleaseCandidate: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -110,10 +110,10 @@ func TestCalculateSemver(t *testing.T) {
|
|||||||
respectExisting: true,
|
respectExisting: true,
|
||||||
strictMode: true,
|
strictMode: true,
|
||||||
want: SemVer{
|
want: SemVer{
|
||||||
Major: 2,
|
Major: 2,
|
||||||
Minor: 0,
|
Minor: 0,
|
||||||
Patch: 1, // Initial tag 2.0.0 + patch from "update" keyword
|
Patch: 1, // Initial tag 2.0.0 + patch from "update" keyword
|
||||||
Release: 1,
|
Release: 1,
|
||||||
EnableReleaseCandidate: true,
|
EnableReleaseCandidate: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ func CheckMatches(content []string, targets []string, blacklist []string) bool {
|
|||||||
if len(matches) > 0 {
|
if len(matches) > 0 {
|
||||||
hasMatch = true
|
hasMatch = true
|
||||||
Debug("Found match", map[string]interface{}{
|
Debug("Found match", map[string]interface{}{
|
||||||
"target": tgt,
|
"target": tgt,
|
||||||
"match": strings.Join(matches, ","),
|
"match": strings.Join(matches, ","),
|
||||||
"content": contentStr,
|
"content": contentStr,
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
@@ -117,7 +117,7 @@ func CheckMatches(content []string, targets []string, blacklist []string) bool {
|
|||||||
for _, blacklistTerm := range blacklist {
|
for _, blacklistTerm := range blacklist {
|
||||||
if strings.Contains(strings.ToLower(contentStr), strings.ToLower(blacklistTerm)) {
|
if strings.Contains(strings.ToLower(contentStr), strings.ToLower(blacklistTerm)) {
|
||||||
Debug("Blacklisted term detected, ignoring commit", map[string]interface{}{
|
Debug("Blacklisted term detected, ignoring commit", map[string]interface{}{
|
||||||
"content": contentStr,
|
"content": contentStr,
|
||||||
"blacklist_term": blacklistTerm,
|
"blacklist_term": blacklistTerm,
|
||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -58,14 +58,14 @@ func TestParseExistingSemver(t *testing.T) {
|
|||||||
InitLogger(false)
|
InitLogger(false)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
tagName string
|
tagName string
|
||||||
currentSemver SemVer
|
currentSemver SemVer
|
||||||
want SemVer
|
want SemVer
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Standard semver",
|
name: "Standard semver",
|
||||||
tagName: "1.2.3",
|
tagName: "1.2.3",
|
||||||
currentSemver: SemVer{},
|
currentSemver: SemVer{},
|
||||||
want: SemVer{
|
want: SemVer{
|
||||||
Major: 1,
|
Major: 1,
|
||||||
@@ -74,8 +74,8 @@ func TestParseExistingSemver(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "With v prefix",
|
name: "With v prefix",
|
||||||
tagName: "v2.3.4",
|
tagName: "v2.3.4",
|
||||||
currentSemver: SemVer{},
|
currentSemver: SemVer{},
|
||||||
want: SemVer{
|
want: SemVer{
|
||||||
Major: 2,
|
Major: 2,
|
||||||
@@ -84,8 +84,8 @@ func TestParseExistingSemver(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "With release candidate",
|
name: "With release candidate",
|
||||||
tagName: "3.4.5-rc.2",
|
tagName: "3.4.5-rc.2",
|
||||||
currentSemver: SemVer{},
|
currentSemver: SemVer{},
|
||||||
want: SemVer{
|
want: SemVer{
|
||||||
Major: 3,
|
Major: 3,
|
||||||
|
|||||||
Reference in New Issue
Block a user