Skip to content

Commit 46d31e8

Browse files
committed
more error msg handling
1 parent 4329364 commit 46d31e8

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

pkg/RepoManages.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,20 @@ func (impl RepoManagerImpl) updatePipelineMaterialCommit(gitCtx git.GitContext,
202202

203203
fetchCount := impl.configuration.GitHistoryCount
204204
var repository *git.GitRepository
205-
commits, _, _, err := impl.repositoryManager.ChangesSinceByRepository(gitCtx, repository, pipelineMaterial.Value, "", "", fetchCount, material.CheckoutLocation, true)
205+
commits, _, errMsg, err := impl.repositoryManager.ChangesSinceByRepository(gitCtx, repository, pipelineMaterial.Value, "", "", fetchCount, material.CheckoutLocation, true)
206206
//commits, err := impl.FetchChanges(pipelineMaterial.Id, "", "", 0)
207207
if gitCtx.Err() != nil {
208208
impl.logger.Errorw("context error in getting commits", "err", gitCtx.Err())
209209
return gitCtx.Err()
210-
} else if err == nil {
210+
} else if err != nil {
211+
pipelineMaterial.Errored = true
212+
if errMsg != "" {
213+
pipelineMaterial.ErrorMsg = errMsg
214+
} else {
215+
pipelineMaterial.ErrorMsg = err.Error()
216+
}
217+
pipelineMaterial.LastSeenHash = ""
218+
} else {
211219
impl.logger.Infow("commits found", "commit", commits)
212220
b, err := json.Marshal(commits)
213221
if err == nil {
@@ -223,13 +231,13 @@ func (impl RepoManagerImpl) updatePipelineMaterialCommit(gitCtx git.GitContext,
223231
pipelineMaterial.ErrorMsg = ""
224232
} else {
225233
pipelineMaterial.Errored = true
226-
pipelineMaterial.ErrorMsg = err.Error()
234+
if errMsg != "" {
235+
pipelineMaterial.ErrorMsg = errMsg
236+
} else {
237+
pipelineMaterial.ErrorMsg = err.Error()
238+
}
227239
pipelineMaterial.LastSeenHash = ""
228240
}
229-
} else {
230-
pipelineMaterial.Errored = true
231-
pipelineMaterial.ErrorMsg = err.Error()
232-
pipelineMaterial.LastSeenHash = ""
233241
}
234242
materialCommits = append(materialCommits, pipelineMaterial)
235243
}

pkg/git/Watcher.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,15 @@ func (impl GitWatcherImpl) pollGitMaterialAndNotify(material *sql.GitMaterial) (
253253
lastSeenHash = material.LastSeenHash
254254
}
255255
fetchCount := impl.configuration.GitHistoryCount
256-
commits, _, _, err := impl.repositoryManager.ChangesSinceByRepository(gitCtx, repo, material.Value, lastSeenHash, "", fetchCount, checkoutLocation, false)
256+
commits, _, errMsg, err := impl.repositoryManager.ChangesSinceByRepository(gitCtx, repo, material.Value, lastSeenHash, "", fetchCount, checkoutLocation, false)
257257
if err != nil {
258258
material.Errored = true
259-
material.ErrorMsg = err.Error()
259+
if errMsg != "" {
260+
material.ErrorMsg = errMsg
261+
} else {
262+
material.ErrorMsg = err.Error()
263+
}
264+
260265
erroredMaterialsModels = append(erroredMaterialsModels, material)
261266
} else if len(commits) > 0 {
262267
latestCommit := commits[0]

0 commit comments

Comments
 (0)