Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-subscribe user to repository when they commit/tag to it #7657

Merged
merged 36 commits into from
Nov 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c0226f2
Add support for AUTO_WATCH_ON_CHANGES and AUTO_WATCH_ON_CLONE
Jul 29, 2019
6c1a039
Update models/repo_watch.go
guillep2k Jul 29, 2019
5d52dda
Round up changes suggested by lafriks
Jul 29, 2019
6e4a28d
Added changes suggested from automated tests
Jul 29, 2019
ce99d45
Updated deleteUser to take RepoWatchModeDont into account, corrected …
Jul 30, 2019
7781419
Merge branch 'master' into watchonchanges
Jul 30, 2019
70790fa
Merge branch 'master' into watchonchanges
Jul 31, 2019
6d039b8
Merge branch 'master' into watchonchanges
guillep2k Aug 8, 2019
3dad90f
Merge branch 'master' into watchonchanges
guillep2k Aug 8, 2019
34643f1
Merge branch 'master' into watchonchanges
guillep2k Aug 15, 2019
4a9fad0
Merge branch 'master' into watchonchanges
guillep2k Aug 15, 2019
2abd413
Reinsert import "github.com/Unknwon/com" on http.go
guillep2k Aug 15, 2019
dd2fa5a
Merge branch 'master' of github.com:go-gitea/gitea into watchonchanges
guillep2k Aug 15, 2019
3034d5e
Add migration for new column `watch`.`mode`
guillep2k Aug 15, 2019
623cfe5
Merge branch 'master' into watchonchanges
guillep2k Aug 22, 2019
d1cc6fb
Merge branch master into watchonchanges
guillep2k Aug 27, 2019
6715664
Remove serv code
guillep2k Aug 27, 2019
00782cf
Remove WATCH_ON_CLONE; use hooks, add integrations
guillep2k Aug 27, 2019
f0377e1
Merge branch 'master' of github.com:go-gitea/gitea into watchonchanges
guillep2k Aug 27, 2019
ff09de9
Renamed watch_test.go to repo_watch_test.go
guillep2k Aug 27, 2019
fde42fa
Correct fmt
guillep2k Aug 27, 2019
0969aa8
Add missing EOL
guillep2k Aug 27, 2019
4a0d89e
Correct name of test function
guillep2k Aug 27, 2019
28a4af3
Merge branch 'master' of github.com:go-gitea/gitea into watchonchanges
guillep2k Aug 29, 2019
3ef2ff1
Merge from master, resolve conflicts
guillep2k Oct 31, 2019
de0852f
Reword cheat and ini descriptions
guillep2k Oct 31, 2019
f0e6aeb
Add update to migration to ensure column value
guillep2k Nov 2, 2019
ad68861
Merge branch 'master' into watchonchanges
guillep2k Nov 2, 2019
df24eb0
Merge branch 'master' into watchonchanges
lunny Nov 2, 2019
4e76559
Merge branch 'master' into watchonchanges
lafriks Nov 5, 2019
edc9f52
Merge master and resolve conflicts
guillep2k Nov 8, 2019
59e6f88
Merge branch 'watchonchanges' of github.com:guillep2k/gitea into watc…
guillep2k Nov 8, 2019
4341a4b
Clarify comment
guillep2k Nov 10, 2019
c59a238
Simplify if condition
guillep2k Nov 10, 2019
8301471
Merge branch 'master' into watchonchanges
lunny Nov 10, 2019
7eec08b
Merge branch 'master' into watchonchanges
zeripath Nov 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove serv code
  • Loading branch information
guillep2k committed Aug 27, 2019
commit 6715664ce4e0047f98c8645cdf8eb6d684a671fb
5 changes: 5 additions & 0 deletions modules/repofiles/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,5 +502,10 @@ func PushUpdate(repo *models.Repository, branch string, opts models.PushUpdateOp
if opts.RefFullName == git.BranchPrefix+repo.DefaultBranch {
models.UpdateRepoIndexer(repo)
}

if err = models.WatchIfAuto(opts.PusherID, repo.ID, true); err != nil {
log.Warn("Fail to perform auto watch on user %v for repo %v: %v", opts.PusherID, repo.ID, err)
}

return nil
}
14 changes: 0 additions & 14 deletions routers/private/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,20 +268,6 @@ func ServCommand(ctx *macaron.Context) {
return
}
}

// Auto-subscribe to repo if not anonymous user and not wiki
if !results.IsWiki && user != nil {
if err = models.WatchIfAuto(user.ID, repo.ID, mode == models.AccessModeWrite); err != nil {
log.Error("Failed to check auto watch for user %-v on %-v Error: %v", user, repo, err)
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
"results": results,
"type": "InternalServerError",
"err": fmt.Sprintf("Failed to check auto watch for user %s on repo %s Error: %v", user.Name, repo.Name, err),
})
return
}
}

log.Debug("Serv Results:\nIsWiki: %t\nIsDeployKey: %t\nKeyID: %d\tKeyName: %s\nUserName: %s\nUserID: %d\nOwnerName: %s\nRepoName: %s\nRepoID: %d",
results.IsWiki,
results.IsDeployKey,
Expand Down
34 changes: 0 additions & 34 deletions routers/repo/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"

"github.com/Unknwon/com"
)

// HTTP implmentation git smart HTTP protocol
Expand Down Expand Up @@ -432,38 +430,6 @@ func serviceRPC(h serviceHandler, service string) {
log.Error("Fail to serve RPC(%s): %v - %s", service, err, stderr.String())
return
}

// Implement automatic watch on upload/receive
if service != "upload-pack" && service != "receive-pack" {
return
}

var (
repoID int64
userID int64
)

// Restore userID and repoID values from context
repoReg := regexp.MustCompile("^" + models.ProtectedBranchRepoID + "=(.*)$")
userReg := regexp.MustCompile("^" + models.EnvPusherID + "=(.*)$")

for _, env := range h.environ {
if m := repoReg.FindStringSubmatch(env); m != nil {
repoID = com.StrTo(m[1]).MustInt64()
}
if m := userReg.FindStringSubmatch(env); m != nil {
userID = com.StrTo(m[1]).MustInt64()
}
}

if userID == 0 || repoID == 0 {
return
}

if err = models.WatchIfAuto(userID, repoID, service == "receive-pack"); err != nil {
log.Warn("Fail to perform auto watch on user %v for repo %v: %v - %v", userID, repoID, err, stderr)
return
}
}

func serviceUploadPack(h serviceHandler) {
Expand Down