Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion git-sensor/pkg/git/RepositoryManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,11 @@ func (impl *RepositoryManagerImpl) Fetch(gitCtx GitContext, url string, location
res, errMsg, err := impl.gitManager.Fetch(gitCtx, location)

if err == nil && len(res) > 0 {
onlySSHWarning := IsOutputOnlySSHWarning(res)
impl.logger.Infow("repository updated", "location", url)
//updated
middleware.GitPullDuration.WithLabelValues("true", "true").Observe(time.Since(start).Seconds())
return true, r, "", nil
return !onlySSHWarning, r, "", nil
} else if err == nil && len(res) == 0 {
impl.logger.Debugw("no update for ", "path", url)
middleware.GitPullDuration.WithLabelValues("true", "false").Observe(time.Since(start).Seconds())
Expand All @@ -263,6 +264,19 @@ func (impl *RepositoryManagerImpl) Fetch(gitCtx GitContext, url string, location

}

func IsOutputOnlySSHWarning(output string) bool {
outputSplit := strings.Split(output, "\n")
if len(outputSplit) > 1 {
return false
}
for _, line := range outputSplit {
if strings.Contains(line, "Warning: Permanently added") {
return true
}
}
return false
}

func (impl *RepositoryManagerImpl) GetCommitForTag(gitCtx GitContext, checkoutPath, tag string) (*GitCommitBase, error) {
var err error
start := time.Now()
Expand Down