Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit b89407c

Browse files
Add last sync flag to start from (#53)
* add last sync flag to start from Signed-off-by: Ayman <[email protected]> * clean up Signed-off-by: Ayman <[email protected]> * clean up Signed-off-by: Ayman <[email protected]> Signed-off-by: Ayman <[email protected]> Co-authored-by: Ayman <[email protected]>
1 parent 60e128f commit b89407c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ENV ELASTIC_LOG_USER='<ELASTIC-LOG-USER>'
1010
ENV ELASTIC_LOG_PASSWORD='<ELASTIC-LOG-PASSWORD>'
1111
ENV GIT_SOURCE_ID='<GIT_SOURCE_ID>'
1212
ENV GIT_REPOSITORY_SOURCE='<GIT_REPOSITORY_SOURCE>'
13+
ENV LAST_SYNC='<LAST_SYNC>'
1314
RUN apk update && apk add git
1415
RUN apk add cloc
1516
RUN apk add --no-cache bash

cmd/git/git.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,6 +2370,15 @@ func (j *DSGit) ParseNextCommit(ctx *shared.Ctx) (commit map[string]interface{},
23702370
// Sync - sync git data source
23712371
func (j *DSGit) Sync(ctx *shared.Ctx) (err error) {
23722372
thrN := shared.GetThreadsNum(ctx)
2373+
lastSync := os.Getenv("LAST_SYNC")
2374+
if lastSync != "" {
2375+
i, err := strconv.ParseInt(lastSync, 10, 64)
2376+
if err != nil {
2377+
return err
2378+
}
2379+
tm := time.Unix(i, 0)
2380+
ctx.DateFrom = &tm
2381+
}
23732382
if ctx.DateFrom != nil {
23742383
j.log.WithFields(logrus.Fields{"operation": "Sync"}).Infof("%s fetching from %v (%d threads)", j.URL, ctx.DateFrom, thrN)
23752384
}

0 commit comments

Comments
 (0)