MCPcopy Create free account
hub / github.com/gogs/gogs / watchRepo

Function watchRepo

internal/database/repo.go:2365–2384  ·  view source on GitHub ↗
(e Engine, userID, repoID int64, watch bool)

Source from the content-addressed store, hash-verified

2363}
2364
2365func watchRepo(e Engine, userID, repoID int64, watch bool) (err error) {
2366 if watch {
2367 if isWatching(e, userID, repoID) {
2368 return nil
2369 }
2370 if _, err = e.Insert(&Watch{RepoID: repoID, UserID: userID}); err != nil {
2371 return err
2372 }
2373 _, err = e.Exec("UPDATE `repository` SET num_watches = num_watches + 1 WHERE id = ?", repoID)
2374 } else {
2375 if !isWatching(e, userID, repoID) {
2376 return nil
2377 }
2378 if _, err = e.Delete(&Watch{0, userID, repoID}); err != nil {
2379 return err
2380 }
2381 _, err = e.Exec("UPDATE `repository` SET num_watches = num_watches - 1 WHERE id = ?", repoID)
2382 }
2383 return err
2384}
2385
2386// Watch or unwatch repository.
2387//

Callers 6

RemoveOrgUserFunction · 0.85
addRepositoryMethod · 0.85
removeRepositoryMethod · 0.85
createRepositoryFunction · 0.85
TransferOwnershipFunction · 0.85
WatchRepoFunction · 0.85

Calls 4

isWatchingFunction · 0.85
InsertMethod · 0.80
ExecMethod · 0.80
DeleteMethod · 0.80

Tested by

no test coverage detected