Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xtreme-shane-lattanzio committed Nov 20, 2023
1 parent 109a903 commit e119c97
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/git/remote_git_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (

const defaultRemote = "origin"

var regex = regexp.MustCompile("[a-f0-9]{40}")

type remoteGitResolver struct{}

func (*remoteGitResolver) Resolve(auth transport.AuthMethod, sourceConfig corev1alpha1.SourceConfig) (corev1alpha1.ResolvedSourceConfig, error) {
Expand Down Expand Up @@ -123,7 +125,7 @@ func resolveSourceWithSubpath(auth transport.AuthMethod, sourceConfig corev1alph
func latestCommitForSubpath(r *gogit.Repository, subPath string) (string, error) {
logOutput, err := r.Log(&gogit.LogOptions{
PathFilter: func(s string) bool {
if strings.Contains(s, subPath) {
if strings.HasPrefix(s, subPath) {
return true
} else {
return false
Expand All @@ -132,7 +134,6 @@ func latestCommitForSubpath(r *gogit.Repository, subPath string) (string, error)
})

latestCommit, err := logOutput.Next()
regex, _ := regexp.Compile("[a-f0-9]{40}")
effectiveCommit := regex.FindString(latestCommit.String())

return effectiveCommit, err
Expand Down

0 comments on commit e119c97

Please sign in to comment.