Skip to content

Commit

Permalink
refactor: use event id instead of uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlJi committed Sep 8, 2024
1 parent ab7b0cd commit 7ebb35b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 9 additions & 0 deletions internal/lintersutil/lintersutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ func FromContext(ctx context.Context) *xlog.Logger {
}
return xlog.New(eventGUID)
}

// GetEventGUID returns the event GUID from the context.
func GetEventGUID(ctx context.Context) string {
eventGUID, ok := ctx.Value(EventGUIDKey).(string)
if !ok {
return "default"
}
return eventGUID
}
3 changes: 1 addition & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (

"github.com/bradleyfalzon/ghinstallation/v2"
"github.com/google/go-github/v57/github"
"github.com/google/uuid"
"github.com/gregjones/httpcache"
"github.com/qiniu/reviewbot/config"
"github.com/qiniu/reviewbot/internal/linters"
Expand Down Expand Up @@ -329,7 +328,7 @@ func (s *Server) handle(ctx context.Context, event *github.PullRequestEvent) err
PullRequestChangedFiles: pullRequestAffectedFiles,
RepoDir: r.Directory(),
Context: ctx,
ID: uuid.New().String(),
ID: lintersutil.GetEventGUID(ctx),
}

if !linters.LinterRelated(name, agent) {
Expand Down

0 comments on commit 7ebb35b

Please sign in to comment.