Skip to content

Commit

Permalink
internal/gaby: actually run github.Add
Browse files Browse the repository at this point in the history
I don't know why but currently gabby does not call github.Add.
And make github.Add no-op if the project is already present in DB
(like CL 627778)

For #51

Change-Id: I9d3760bad50186a2f03e20f46d76ef164ac675f3
Reviewed-on: https://go-review.googlesource.com/c/oscar/+/629355
Reviewed-by: Zvonimir Pavlinovic <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
hyangah committed Nov 18, 2024
1 parent 61d708c commit 44d59a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions internal/gaby/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ func main() {
defer shutdown()

g.github = github.New(g.slog, g.db, g.secret, g.http)
for _, project := range g.githubProjects {
if err := g.github.Add(project); err != nil {
log.Fatalf("github.Add failed: %v", err)
}
}
g.disc = discussion.New(g.ctx, g.slog, g.secret, g.db)
for _, project := range g.githubProjects {
if err := g.disc.Add(project); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/github/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ func (proj *projectSync) store(db storage.DB) {
// to the database.
// It only adds the project sync metadata.
// The initial data fetch does not happen until [Sync] or [SyncProject] is called.
// Add returns an error if the project has already been added.
// If the project is already present, Add does nothing and returns nil.
func (c *Client) Add(project string) error {
key := o(syncProjectKind, project)
if _, ok := c.db.Get(key); ok {
return fmt.Errorf("github.Add: already added: %q", project)
return nil
}
c.db.Set(key, storage.JSON(&projectSync{Name: project}))
return nil
Expand Down

0 comments on commit 44d59a0

Please sign in to comment.