Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Version
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Utilities
Version
Commits
48a7528c
Verified
Commit
48a7528c
authored
1 year ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: read log
parent
a30ca8b2
Branches
Branches containing commit
Tags
0.2.1
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
commandline.go
+2
-1
2 additions, 1 deletion
commandline.go
git.go
+17
-1
17 additions, 1 deletion
git.go
version.go
+4
-0
4 additions, 0 deletions
version.go
with
23 additions
and
2 deletions
commandline.go
+
2
−
1
View file @
48a7528c
...
...
@@ -96,7 +96,8 @@ func executeCommand() {
case
FixCommit
:
command
=
"patch"
case
OtherCommit
:
fmt
.
Println
(
"No changes found"
)
fmt
.
Println
(
"No notable changes found."
)
fmt
.
Println
(
"If you want to force a version
\n
increase, use the major, minor
\n
or patch command."
)
os
.
Exit
(
0
)
}
...
...
This diff is collapsed.
Click to expand it.
git.go
+
17
−
1
View file @
48a7528c
...
...
@@ -7,6 +7,7 @@ import (
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/storer"
)
type
CommitType
int
...
...
@@ -83,28 +84,43 @@ func getLatestTagCommit(r *git.Repository) (*object.Commit, error) {
}
func
getCommitTypeSinceTag
(
r
*
git
.
Repository
,
tagCommit
*
object
.
Commit
)
(
CommitType
,
error
)
{
cIter
,
err
:=
r
.
Log
(
&
git
.
LogOptions
{
From
:
tagCommit
.
Hash
})
cIter
,
err
:=
r
.
Log
(
&
git
.
LogOptions
{})
if
err
!=
nil
{
return
OtherCommit
,
fmt
.
Errorf
(
"failed to get commit log: %v"
,
err
)
}
var
commitType
CommitType
found
:=
false
err
=
cIter
.
ForEach
(
func
(
commit
*
object
.
Commit
)
error
{
if
commit
.
Hash
==
tagCommit
.
Hash
{
found
=
true
return
storer
.
ErrStop
// stop iteration
}
if
strings
.
HasPrefix
(
commit
.
Message
,
"feat:"
)
{
commitType
=
FeatCommit
found
=
true
return
storer
.
ErrStop
// stop iteration
}
else
if
strings
.
HasPrefix
(
commit
.
Message
,
"fix:"
)
{
commitType
=
FixCommit
}
else
if
containsBreakingChangeFooter
(
commit
.
Message
)
{
commitType
=
BreakingCommit
found
=
true
return
storer
.
ErrStop
// stop iteration
}
else
{
commitType
=
OtherCommit
}
return
nil
})
if
err
!=
nil
{
return
OtherCommit
,
fmt
.
Errorf
(
"failed to iterate over commit log: %v"
,
err
)
}
if
!
found
{
return
OtherCommit
,
fmt
.
Errorf
(
"tag commit not found in commit log"
)
}
return
commitType
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
version.go
+
4
−
0
View file @
48a7528c
...
...
@@ -212,6 +212,10 @@ func getVersion() (*semver.Version, error) {
}
func
writeVersionToJson
(
version
string
)
error
{
if
content
==
nil
{
return
fmt
.
Errorf
(
"content is nil"
)
}
result
,
err
:=
sjson
.
Set
(
string
(
content
),
arguments
.
Selector
,
version
)
if
err
!=
nil
{
return
err
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment