Browse Source

[routes/user] Minimise upstream diff

We filter out annex-related actions from the user's dashboard feed.
Split out the code that does the filtering to its own function in its
own file.
Achilleas Koutsou 6 năm trước cách đây
mục cha
commit
6197d8af06
2 tập tin đã thay đổi với 18 bổ sung15 xóa
  1. 2 15
      routes/user/home.go
  2. 16 0
      routes/user/user_gin.go

+ 2 - 15
routes/user/home.go

@@ -15,8 +15,6 @@ import (
 	"github.com/G-Node/gogs/models/errors"
 	"github.com/G-Node/gogs/pkg/context"
 	"github.com/G-Node/gogs/pkg/setting"
-	log "gopkg.in/clog.v1"
-	"strings"
 )
 
 const (
@@ -80,19 +78,8 @@ func retrieveFeeds(c *context.Context, ctxUser *models.User, userID int64, isPro
 		}
 
 		act.ActAvatar = unameAvatars[act.ActUserName]
-
-		// This filters branches from the feed
-		switch {
-		case strings.Contains(act.RefName, "synced/git-annex"):
-			log.Trace("Ignored Ref %s for feed", act.RefName)
-		case strings.Contains(act.RefName, "synced/master"):
-			log.Trace("Ignored Ref %s for feed", act.RefName)
-		case strings.Contains(act.RefName, "git-annex"):
-			log.Trace("Ignored Ref %s for feed", act.RefName)
-		case strings.Contains(act.RepoName, "hideme") || strings.Contains(act.RepoName, "unlisted"):
-			log.Trace("Ignored Ref %s for feed", act.RefName)
-		default:
-			log.Trace("Added Ref %s for feed", act.RefName)
+		// GIN mod: Feed filtering for annex branches
+		if !excludeFromFeed(act) {
 			feeds = append(feeds, act)
 		}
 	}

+ 16 - 0
routes/user/user_gin.go

@@ -0,0 +1,16 @@
+package user
+
+import (
+	"strings"
+
+	"github.com/G-Node/gogs/models"
+)
+
+// excludeFromFeed returns 'true' if the given action should be excluded from the user feed.
+func excludeFromFeed(act *models.Action) bool {
+	return strings.Contains(act.RefName, "synced/git-annex") ||
+		strings.Contains(act.RefName, "synced/master") ||
+		strings.Contains(act.RefName, "git-annex") ||
+		strings.Contains(act.RepoName, "hideme") ||
+		strings.Contains(act.RepoName, "unlisted")
+}