From 8e17df50d59c1cfa751fb31e810bce415c3e0cfc Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 24 Jul 2018 09:27:01 +0800 Subject: [PATCH 01/21] feat(repo): support search repository by topic name --- models/repo_list.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/models/repo_list.go b/models/repo_list.go index b1527b73c9f42..644aceabea2e1 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -202,7 +202,10 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, err } if opts.Keyword != "" { - cond = cond.And(builder.Like{"lower_name", strings.ToLower(opts.Keyword)}) + var keywordCond = builder.NewCond() + keywordCond = keywordCond.Or(builder.Like{"lower_name", strings.ToLower(opts.Keyword)}) + keywordCond = keywordCond.Or(builder.Like{"topic.name", strings.ToLower(opts.Keyword)}) + cond = cond.And(keywordCond) } if opts.Fork != util.OptionalBoolNone { @@ -224,6 +227,11 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, err sess.Join("INNER", "star", "star.repo_id = repository.id") } + if opts.Keyword != "" { + sess.Join("LEFT", "repo_topic", "repo_topic.repo_id = repository.id") + sess.Join("LEFT", "topic", "repo_topic.topic_id = topic.id") + } + count, err := sess. Where(cond). Count(new(Repository)) @@ -236,11 +244,23 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, err sess.Join("INNER", "star", "star.repo_id = repository.id") } + if opts.Keyword != "" { + sess.Join("LEFT", "repo_topic", "repo_topic.repo_id = repository.id") + sess.Join("LEFT", "topic", "repo_topic.topic_id = topic.id") + } + + if opts.Keyword != "" { + sess = sess.Select("repository.*") + sess = sess.GroupBy("repository.id") + sess = sess.OrderBy("repository." + opts.OrderBy.String()) + } else { + sess = sess.OrderBy(opts.OrderBy.String()) + } + repos := make(RepositoryList, 0, opts.PageSize) if err = sess. Where(cond). Limit(opts.PageSize, (opts.Page-1)*opts.PageSize). - OrderBy(opts.OrderBy.String()). Find(&repos); err != nil { return nil, 0, fmt.Errorf("Repo: %v", err) } From a0f21a562ad32f216028939c572c2f0b570cde25 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 24 Jul 2018 10:14:12 +0800 Subject: [PATCH 02/21] fix: testing --- models/repo_list.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/repo_list.go b/models/repo_list.go index 644aceabea2e1..1d7020aa8e9f0 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -184,7 +184,7 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, err if opts.Collaborate != util.OptionalBoolFalse { collaborateCond := builder.And( - builder.Expr("id IN (SELECT repo_id FROM `access` WHERE access.user_id = ?)", opts.OwnerID), + builder.Expr("repository.id IN (SELECT repo_id FROM `access` WHERE access.user_id = ?)", opts.OwnerID), builder.Neq{"owner_id": opts.OwnerID}) if !opts.Private { collaborateCond = collaborateCond.And(builder.Expr("owner_id NOT IN (SELECT org_id FROM org_user WHERE org_user.uid = ? AND org_user.is_public = ?)", opts.OwnerID, false)) @@ -235,6 +235,7 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, err count, err := sess. Where(cond). Count(new(Repository)) + if err != nil { return nil, 0, fmt.Errorf("Count: %v", err) } From ae1cd1a1c01a7543b624ca500874a63f7c7ff907 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 24 Jul 2018 11:15:54 +0800 Subject: [PATCH 03/21] test: Add search topic testing. --- models/fixtures/repo_topic.yml | 4 ++++ models/repo_list.go | 8 ++++---- models/repo_list_test.go | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/models/fixtures/repo_topic.yml b/models/fixtures/repo_topic.yml index 58937031cd9cf..3a27442d4362c 100644 --- a/models/fixtures/repo_topic.yml +++ b/models/fixtures/repo_topic.yml @@ -9,3 +9,7 @@ - repo_id: 1 topic_id: 3 + +- + repo_id: 2 + topic_id: 2 diff --git a/models/repo_list.go b/models/repo_list.go index 1d7020aa8e9f0..c9183166db97c 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -251,11 +251,11 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, err } if opts.Keyword != "" { - sess = sess.Select("repository.*") - sess = sess.GroupBy("repository.id") - sess = sess.OrderBy("repository." + opts.OrderBy.String()) + sess.Select("repository.*") + sess.GroupBy("repository.id") + sess.OrderBy("repository." + opts.OrderBy.String()) } else { - sess = sess.OrderBy(opts.OrderBy.String()) + sess.OrderBy(opts.OrderBy.String()) } repos := make(RepositoryList, 0, opts.PageSize) diff --git a/models/repo_list_test.go b/models/repo_list_test.go index 4b5d659ce2b95..0965aebcb3b1e 100644 --- a/models/repo_list_test.go +++ b/models/repo_list_test.go @@ -222,3 +222,28 @@ func TestSearchRepositoryByName(t *testing.T) { }) } } + +func TestSearchRepositoryByTopicName(t *testing.T) { + assert.NoError(t, PrepareTestDatabase()) + + testCases := []struct { + name string + opts *SearchRepoOptions + count int + }{ + {name: "AllPublic/SearchPublicRepositoriesFromTopic", + opts: &SearchRepoOptions{OwnerID: 2, AllPublic: true, Keyword: "golang"}, + count: 1}, + {name: "AllPublic/SearchPrivareRepositoriesFromTopic", + opts: &SearchRepoOptions{OwnerID: 2, AllPublic: true, Keyword: "database", Private: true}, + count: 2}, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + _, count, err := SearchRepositoryByName(testCase.opts) + assert.NoError(t, err) + assert.Equal(t, int64(testCase.count), count) + }) + } +} From 1546c5ce8a81c71e782255cfccb9d89007618890 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 24 Jul 2018 11:22:51 +0800 Subject: [PATCH 04/21] fix: typo --- models/repo_list_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/repo_list_test.go b/models/repo_list_test.go index 0965aebcb3b1e..576dfe0b30b50 100644 --- a/models/repo_list_test.go +++ b/models/repo_list_test.go @@ -234,7 +234,7 @@ func TestSearchRepositoryByTopicName(t *testing.T) { {name: "AllPublic/SearchPublicRepositoriesFromTopic", opts: &SearchRepoOptions{OwnerID: 2, AllPublic: true, Keyword: "golang"}, count: 1}, - {name: "AllPublic/SearchPrivareRepositoriesFromTopic", + {name: "AllPublic/SearchPrivateRepositoriesFromTopic", opts: &SearchRepoOptions{OwnerID: 2, AllPublic: true, Keyword: "database", Private: true}, count: 2}, } From 29866c50bb01b5d510292ee065926bb72555f10d Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 24 Jul 2018 13:58:16 +0800 Subject: [PATCH 05/21] feat: support click mode --- templates/explore/repo_list.tmpl | 2 +- templates/repo/home.tmpl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index b8f4490c112c5..4b5135ed0c694 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -20,7 +20,7 @@ {{if .Topics }}
{{range .Topics}} - {{if ne . "" }}
{{.}}
{{end}} + {{if ne . "" }}
{{.}}
{{end}} {{end}}
{{end}} diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index f14f2b9a2865e..983ef4eb4d99f 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -24,8 +24,8 @@ {{end}}
- {{range .Topics}}
{{.Name}}
{{end}} - {{if .IsRepositoryAdmin}}{{.i18n.Tr "repo.topic.manage_topics"}}{{end}} + {{range .Topics}}{{.Name}}{{end}} + {{if .IsRepositoryAdmin}}{{.i18n.Tr "repo.topic.manage_topics"}}{{end}}
{{if .IsRepositoryAdmin}}
@@ -34,7 +34,7 @@ From 0e98af3a2d97fca4a925b7e6309358996ab56f43 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 30 Jul 2018 11:41:19 +0800 Subject: [PATCH 06/21] feat: support only search by topic name. --- models/fixtures/repository.yml | 8 ++++++-- models/repo_list.go | 10 ++++++++-- models/repo_list_test.go | 3 +++ routers/api/v1/repo/repo.go | 1 + routers/home.go | 2 ++ routers/user/profile.go | 4 ++++ templates/explore/repo_list.tmpl | 2 +- templates/repo/home.tmpl | 6 +++--- 8 files changed, 28 insertions(+), 8 deletions(-) diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index 54f3ed7b097d9..d095913e2d7bb 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -404,6 +404,10 @@ - id: 33 owner_id: 2 - lower_name: utf8 - name: utf8 + lower_name: golang-1 + name: golang-1 is_private: false + num_stars: 0 + num_forks: 0 + num_issues: 0 + is_mirror: false diff --git a/models/repo_list.go b/models/repo_list.go index c9183166db97c..eb9a2269dcc1e 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -131,6 +131,8 @@ type SearchRepoOptions struct { // True -> include just mirrors // False -> include just non-mirrors Mirror util.OptionalBool + // only search topic name + Topic bool } //SearchOrderBy is used to sort the result @@ -203,8 +205,12 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, err if opts.Keyword != "" { var keywordCond = builder.NewCond() - keywordCond = keywordCond.Or(builder.Like{"lower_name", strings.ToLower(opts.Keyword)}) - keywordCond = keywordCond.Or(builder.Like{"topic.name", strings.ToLower(opts.Keyword)}) + if opts.Topic { + keywordCond = keywordCond.Or(builder.Like{"topic.name", strings.ToLower(opts.Keyword)}) + } else { + keywordCond = keywordCond.Or(builder.Like{"lower_name", strings.ToLower(opts.Keyword)}) + keywordCond = keywordCond.Or(builder.Like{"topic.name", strings.ToLower(opts.Keyword)}) + } cond = cond.And(keywordCond) } diff --git a/models/repo_list_test.go b/models/repo_list_test.go index 576dfe0b30b50..dd9aa6a3499ba 100644 --- a/models/repo_list_test.go +++ b/models/repo_list_test.go @@ -233,6 +233,9 @@ func TestSearchRepositoryByTopicName(t *testing.T) { }{ {name: "AllPublic/SearchPublicRepositoriesFromTopic", opts: &SearchRepoOptions{OwnerID: 2, AllPublic: true, Keyword: "golang"}, + count: 2}, + {name: "AllPublic/OnlySearchPublicRepositoriesFromTopic", + opts: &SearchRepoOptions{OwnerID: 2, AllPublic: true, Keyword: "golang", Topic: true}, count: 1}, {name: "AllPublic/SearchPrivateRepositoriesFromTopic", opts: &SearchRepoOptions{OwnerID: 2, AllPublic: true, Keyword: "database", Private: true}, diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 90acde2eeaf9d..d0fa4a02e7c9f 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -91,6 +91,7 @@ func Search(ctx *context.APIContext) { OwnerID: ctx.QueryInt64("uid"), Page: ctx.QueryInt("page"), PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")), + Topic: ctx.QueryBool("topic"), Collaborate: util.OptionalBoolNone, } diff --git a/routers/home.go b/routers/home.go index 0aa907658c51e..d9a118cad0367 100644 --- a/routers/home.go +++ b/routers/home.go @@ -122,6 +122,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { } keyword := strings.Trim(ctx.Query("q"), " ") + topic := ctx.QueryBool("topic") repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{ Page: page, @@ -131,6 +132,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { Keyword: keyword, OwnerID: opts.OwnerID, AllPublic: true, + Topic: topic, }) if err != nil { ctx.ServerError("SearchRepositoryByName", err) diff --git a/routers/user/profile.go b/routers/user/profile.go index fb731e715ca74..974244941f7cc 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -105,6 +105,8 @@ func Profile(ctx *context.Context) { page = 1 } + topic := ctx.QueryBool("topic") + var ( repos []*models.Repository count int64 @@ -174,6 +176,7 @@ func Profile(ctx *context.Context) { PageSize: setting.UI.User.RepoPagingNum, Starred: true, Collaborate: util.OptionalBoolFalse, + Topic: topic, }) if err != nil { ctx.ServerError("SearchRepositoryByName", err) @@ -217,6 +220,7 @@ func Profile(ctx *context.Context) { IsProfile: true, PageSize: setting.UI.User.RepoPagingNum, Collaborate: util.OptionalBoolFalse, + Topic: topic, }) if err != nil { ctx.ServerError("SearchRepositoryByName", err) diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index 4b5135ed0c694..e769e4b7fdae8 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -20,7 +20,7 @@ {{if .Topics }}
{{range .Topics}} - {{if ne . "" }}
{{.}}
{{end}} + {{if ne . "" }}
{{.}}
{{end}} {{end}}
{{end}} diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 983ef4eb4d99f..d5a1416cf6ec9 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -24,8 +24,8 @@ {{end}}
- {{range .Topics}}{{.Name}}{{end}} - {{if .IsRepositoryAdmin}}{{.i18n.Tr "repo.topic.manage_topics"}}{{end}} + {{range .Topics}}{{.Name}}{{end}} + {{if .IsRepositoryAdmin}}{{.i18n.Tr "repo.topic.manage_topics"}}{{end}}
{{if .IsRepositoryAdmin}}
@@ -34,7 +34,7 @@ From 3b6aa567fd3560724a6e949c550c480ec9cca574 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 30 Jul 2018 15:55:49 +0800 Subject: [PATCH 07/21] fix: testing --- models/fixtures/repository.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index d095913e2d7bb..d97f098a28870 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -404,8 +404,8 @@ - id: 33 owner_id: 2 - lower_name: golang-1 - name: golang-1 + lower_name: golang + name: golang is_private: false num_stars: 0 num_forks: 0 From b612c77c083cb4c29bc688e1ae34fdd35afb21fe Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 30 Jul 2018 16:26:10 +0800 Subject: [PATCH 08/21] fix coding style Signed-off-by: Bo-Yi Wu --- models/ssh_key.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/ssh_key.go b/models/ssh_key.go index 997e8ee99758d..9c839755c8b6e 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -18,14 +18,14 @@ import ( "sync" "time" - "github.com/Unknwon/com" - "github.com/go-xorm/xorm" - "golang.org/x/crypto/ssh" - "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" + + "github.com/Unknwon/com" + "github.com/go-xorm/xorm" + "golang.org/x/crypto/ssh" ) const ( From 67dfb3a0de09b4d42baa7a7c62cdd3deac193caf Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 31 Jul 2018 14:20:40 +0800 Subject: [PATCH 09/21] fix: add golang repo --- .../user2/golang.git/HEAD | 1 + .../user2/golang.git/config | 4 + .../user2/golang.git/description | 1 + .../golang.git/hooks/applypatch-msg.sample | 15 ++ .../user2/golang.git/hooks/commit-msg.sample | 24 +++ .../user2/golang.git/hooks/post-receive | 7 + .../golang.git/hooks/post-receive.d/gitea | 2 + .../user2/golang.git/hooks/post-update.sample | 8 + .../golang.git/hooks/pre-applypatch.sample | 14 ++ .../user2/golang.git/hooks/pre-commit.sample | 49 +++++ .../user2/golang.git/hooks/pre-push.sample | 53 ++++++ .../user2/golang.git/hooks/pre-rebase.sample | 169 ++++++++++++++++++ .../user2/golang.git/hooks/pre-receive | 7 + .../golang.git/hooks/pre-receive.d/gitea | 2 + .../hooks/prepare-commit-msg.sample | 36 ++++ .../user2/golang.git/hooks/update | 7 + .../user2/golang.git/hooks/update.d/gitea | 2 + .../user2/golang.git/hooks/update.sample | 128 +++++++++++++ .../user2/golang.git/info/exclude | 6 + .../user2/golang.git/info/refs | 1 + .../2a/2f1d4670728a2e10049e345bd7a276468beab6 | Bin 0 -> 54 bytes .../4b/4851ad51df6a7d9f25c979345979eaeb5b349f | Bin 0 -> 42 bytes .../65/f1bf27bc3bf70f64657658635e66094edbcb4d | Bin 0 -> 150 bytes .../user2/golang.git/objects/info/packs | 1 + .../user2/golang.git/refs/heads/DefaultBranch | 1 + .../user2/golang.git/refs/heads/develop | 1 + .../user2/golang.git/refs/heads/feature/1 | 1 + .../user2/golang.git/refs/heads/master | 1 + .../user2/golang.git/refs/tags/v1.1 | 1 + 29 files changed, 542 insertions(+) create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/HEAD create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/config create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/description create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/applypatch-msg.sample create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/commit-msg.sample create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive.d/gitea create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/post-update.sample create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-applypatch.sample create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-commit.sample create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-push.sample create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-rebase.sample create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive.d/gitea create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/prepare-commit-msg.sample create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/update create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/update.d/gitea create mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/update.sample create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/info/exclude create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/info/refs create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/objects/4b/4851ad51df6a7d9f25c979345979eaeb5b349f create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/objects/65/f1bf27bc3bf70f64657658635e66094edbcb4d create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/objects/info/packs create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/refs/heads/DefaultBranch create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/refs/heads/develop create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/refs/heads/feature/1 create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/refs/heads/master create mode 100644 integrations/gitea-repositories-meta/user2/golang.git/refs/tags/v1.1 diff --git a/integrations/gitea-repositories-meta/user2/golang.git/HEAD b/integrations/gitea-repositories-meta/user2/golang.git/HEAD new file mode 100644 index 0000000000000..cb089cd89a7d7 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/integrations/gitea-repositories-meta/user2/golang.git/config b/integrations/gitea-repositories-meta/user2/golang.git/config new file mode 100644 index 0000000000000..07d359d07cf1e --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/config @@ -0,0 +1,4 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true diff --git a/integrations/gitea-repositories-meta/user2/golang.git/description b/integrations/gitea-repositories-meta/user2/golang.git/description new file mode 100644 index 0000000000000..498b267a8c781 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/applypatch-msg.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/applypatch-msg.sample new file mode 100755 index 0000000000000..a5d7b84a67345 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/commit-msg.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/commit-msg.sample new file mode 100755 index 0000000000000..b58d1184a9d43 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive b/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive new file mode 100755 index 0000000000000..4b3d452abcce2 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +ORI_DIR=`pwd` +SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) +cd "$ORI_DIR" +for i in `ls "$SHELL_FOLDER/post-receive.d"`; do + sh "$SHELL_FOLDER/post-receive.d/$i" +done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive.d/gitea b/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive.d/gitea new file mode 100755 index 0000000000000..43a948da3a983 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive.d/gitea @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" post-receive diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-update.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-update.sample new file mode 100755 index 0000000000000..ec17ec1939b7c --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-applypatch.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-applypatch.sample new file mode 100755 index 0000000000000..4142082bcb939 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-commit.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-commit.sample new file mode 100755 index 0000000000000..68d62d5446d96 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-push.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-push.sample new file mode 100755 index 0000000000000..6187dbf4390fc --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-rebase.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-rebase.sample new file mode 100755 index 0000000000000..33730ca647cb2 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up-to-date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive new file mode 100755 index 0000000000000..412701305369c --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +ORI_DIR=`pwd` +SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) +cd "$ORI_DIR" +for i in `ls "$SHELL_FOLDER/pre-receive.d"`; do + sh "$SHELL_FOLDER/pre-receive.d/$i" +done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive.d/gitea b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive.d/gitea new file mode 100755 index 0000000000000..49d09406364a5 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive.d/gitea @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" pre-receive diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/prepare-commit-msg.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/prepare-commit-msg.sample new file mode 100755 index 0000000000000..f093a02ec4991 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/prepare-commit-msg.sample @@ -0,0 +1,36 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first comments out the +# "Conflicts:" part of a merge commit. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +case "$2,$3" in + merge,) + /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; + +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$1" ;; + + *) ;; +esac + +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/update b/integrations/gitea-repositories-meta/user2/golang.git/hooks/update new file mode 100755 index 0000000000000..c186fe4a18b0f --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/update @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +ORI_DIR=`pwd` +SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) +cd "$ORI_DIR" +for i in `ls "$SHELL_FOLDER/update.d"`; do + sh "$SHELL_FOLDER/update.d/$i" $1 $2 $3 +done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.d/gitea b/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.d/gitea new file mode 100755 index 0000000000000..38101c242664a --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.d/gitea @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" update $1 $2 $3 diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.sample new file mode 100755 index 0000000000000..80ba94135cc37 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to block unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/integrations/gitea-repositories-meta/user2/golang.git/info/exclude b/integrations/gitea-repositories-meta/user2/golang.git/info/exclude new file mode 100644 index 0000000000000..a5196d1be8fb5 --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/integrations/gitea-repositories-meta/user2/golang.git/info/refs b/integrations/gitea-repositories-meta/user2/golang.git/info/refs new file mode 100644 index 0000000000000..ca1df85e2ebfb --- /dev/null +++ b/integrations/gitea-repositories-meta/user2/golang.git/info/refs @@ -0,0 +1 @@ +65f1bf27bc3bf70f64657658635e66094edbcb4d refs/heads/master diff --git a/integrations/gitea-repositories-meta/user2/golang.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 b/integrations/gitea-repositories-meta/user2/golang.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 new file mode 100644 index 0000000000000000000000000000000000000000..0994add2c8a420ba89b9a239de84741d4d00ee02 GIT binary patch literal 54 zcmV-60LlM&0V^p=O;s>9XD~D{Ff%bx2y%6F@paY9O=0l%2wWR@KdW}W>d8uz$jVo* MqfO=m05RYX?j~gyApigX literal 0 HcmV?d00001 diff --git a/integrations/gitea-repositories-meta/user2/golang.git/objects/4b/4851ad51df6a7d9f25c979345979eaeb5b349f b/integrations/gitea-repositories-meta/user2/golang.git/objects/4b/4851ad51df6a7d9f25c979345979eaeb5b349f new file mode 100644 index 0000000000000000000000000000000000000000..700a13828e63248a392e4c90d92bbb6e3dd57ba0 GIT binary patch literal 42 ycmb%v7rOCc0q7S-{K(sSa& zkkbhiI`12U*27++lwz~nt#W~Lz0(ZW%yS%} Date: Tue, 31 Jul 2018 14:53:09 +0800 Subject: [PATCH 10/21] fix: testing --- integrations/api_repo_test.go | 6 +- .../user2/golang.git/HEAD | 1 - .../user2/golang.git/config | 4 - .../user2/golang.git/description | 1 - .../golang.git/hooks/applypatch-msg.sample | 15 -- .../user2/golang.git/hooks/commit-msg.sample | 24 --- .../user2/golang.git/hooks/post-receive | 7 - .../golang.git/hooks/post-receive.d/gitea | 2 - .../user2/golang.git/hooks/post-update.sample | 8 - .../golang.git/hooks/pre-applypatch.sample | 14 -- .../user2/golang.git/hooks/pre-commit.sample | 49 ----- .../user2/golang.git/hooks/pre-push.sample | 53 ------ .../user2/golang.git/hooks/pre-rebase.sample | 169 ------------------ .../user2/golang.git/hooks/pre-receive | 7 - .../golang.git/hooks/pre-receive.d/gitea | 2 - .../hooks/prepare-commit-msg.sample | 36 ---- .../user2/golang.git/hooks/update | 7 - .../user2/golang.git/hooks/update.d/gitea | 2 - .../user2/golang.git/hooks/update.sample | 128 ------------- .../user2/golang.git/info/exclude | 6 - .../user2/golang.git/info/refs | 1 - .../2a/2f1d4670728a2e10049e345bd7a276468beab6 | Bin 54 -> 0 bytes .../4b/4851ad51df6a7d9f25c979345979eaeb5b349f | Bin 42 -> 0 bytes .../65/f1bf27bc3bf70f64657658635e66094edbcb4d | Bin 150 -> 0 bytes .../user2/golang.git/objects/info/packs | 1 - .../user2/golang.git/refs/heads/DefaultBranch | 1 - .../user2/golang.git/refs/heads/develop | 1 - .../user2/golang.git/refs/heads/feature/1 | 1 - .../user2/golang.git/refs/heads/master | 1 - .../user2/golang.git/refs/tags/v1.1 | 1 - models/fixtures/repo_topic.yml | 8 +- models/fixtures/repository.yml | 13 +- models/fixtures/topic.yml | 6 +- models/fixtures/user.yml | 17 +- models/repo_list_test.go | 15 +- 35 files changed, 48 insertions(+), 559 deletions(-) delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/HEAD delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/config delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/description delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/applypatch-msg.sample delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/commit-msg.sample delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive.d/gitea delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/post-update.sample delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-applypatch.sample delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-commit.sample delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-push.sample delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-rebase.sample delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive.d/gitea delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/prepare-commit-msg.sample delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/update delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/update.d/gitea delete mode 100755 integrations/gitea-repositories-meta/user2/golang.git/hooks/update.sample delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/info/exclude delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/info/refs delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/objects/4b/4851ad51df6a7d9f25c979345979eaeb5b349f delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/objects/65/f1bf27bc3bf70f64657658635e66094edbcb4d delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/objects/info/packs delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/refs/heads/DefaultBranch delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/refs/heads/develop delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/refs/heads/feature/1 delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/refs/heads/master delete mode 100644 integrations/gitea-repositories-meta/user2/golang.git/refs/tags/v1.1 diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go index 3fa2ae21dc03e..3f3ffb63c0703 100644 --- a/integrations/api_repo_test.go +++ b/integrations/api_repo_test.go @@ -67,9 +67,9 @@ func TestAPISearchRepo(t *testing.T) { expectedResults }{ {name: "RepositoriesMax50", requestURL: "/api/v1/repos/search?limit=50", expectedResults: expectedResults{ - nil: {count: 17}, - user: {count: 17}, - user2: {count: 17}}, + nil: {count: 16}, + user: {count: 16}, + user2: {count: 16}}, }, {name: "RepositoriesMax10", requestURL: "/api/v1/repos/search?limit=10", expectedResults: expectedResults{ nil: {count: 10}, diff --git a/integrations/gitea-repositories-meta/user2/golang.git/HEAD b/integrations/gitea-repositories-meta/user2/golang.git/HEAD deleted file mode 100644 index cb089cd89a7d7..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/integrations/gitea-repositories-meta/user2/golang.git/config b/integrations/gitea-repositories-meta/user2/golang.git/config deleted file mode 100644 index 07d359d07cf1e..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/config +++ /dev/null @@ -1,4 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = true diff --git a/integrations/gitea-repositories-meta/user2/golang.git/description b/integrations/gitea-repositories-meta/user2/golang.git/description deleted file mode 100644 index 498b267a8c781..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/applypatch-msg.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/applypatch-msg.sample deleted file mode 100755 index a5d7b84a67345..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/applypatch-msg.sample +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message taken by -# applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. The hook is -# allowed to edit the commit message file. -# -# To enable this hook, rename this file to "applypatch-msg". - -. git-sh-setup -commitmsg="$(git rev-parse --git-path hooks/commit-msg)" -test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} -: diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/commit-msg.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/commit-msg.sample deleted file mode 100755 index b58d1184a9d43..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/commit-msg.sample +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message. -# Called by "git commit" with one argument, the name of the file -# that has the commit message. The hook should exit with non-zero -# status after issuing an appropriate message if it wants to stop the -# commit. The hook is allowed to edit the commit message file. -# -# To enable this hook, rename this file to "commit-msg". - -# Uncomment the below to add a Signed-off-by line to the message. -# Doing this in a hook is a bad idea in general, but the prepare-commit-msg -# hook is more suited to it. -# -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" - -# This example catches duplicate Signed-off-by lines. - -test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { - echo >&2 Duplicate Signed-off-by lines. - exit 1 -} diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive b/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive deleted file mode 100755 index 4b3d452abcce2..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -ORI_DIR=`pwd` -SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) -cd "$ORI_DIR" -for i in `ls "$SHELL_FOLDER/post-receive.d"`; do - sh "$SHELL_FOLDER/post-receive.d/$i" -done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive.d/gitea b/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive.d/gitea deleted file mode 100755 index 43a948da3a983..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-receive.d/gitea +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" post-receive diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-update.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-update.sample deleted file mode 100755 index ec17ec1939b7c..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/post-update.sample +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare a packed repository for use over -# dumb transports. -# -# To enable this hook, rename this file to "post-update". - -exec git update-server-info diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-applypatch.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-applypatch.sample deleted file mode 100755 index 4142082bcb939..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-applypatch.sample +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed -# by applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-applypatch". - -. git-sh-setup -precommit="$(git rev-parse --git-path hooks/pre-commit)" -test -x "$precommit" && exec "$precommit" ${1+"$@"} -: diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-commit.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-commit.sample deleted file mode 100755 index 68d62d5446d96..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-commit.sample +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed. -# Called by "git commit" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message if -# it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-commit". - -if git rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi - -# If you want to allow non-ASCII filenames set this variable to true. -allownonascii=$(git config --bool hooks.allownonascii) - -# Redirect output to stderr. -exec 1>&2 - -# Cross platform projects tend to avoid non-ASCII filenames; prevent -# them from being added to the repository. We exploit the fact that the -# printable range starts at the space character and ends with tilde. -if [ "$allownonascii" != "true" ] && - # Note that the use of brackets around a tr range is ok here, (it's - # even required, for portability to Solaris 10's /usr/bin/tr), since - # the square bracket bytes happen to fall in the designated range. - test $(git diff --cached --name-only --diff-filter=A -z $against | - LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 -then - cat <<\EOF -Error: Attempt to add a non-ASCII file name. - -This can cause problems if you want to work with people on other platforms. - -To be portable it is advisable to rename the file. - -If you know what you are doing you can disable this check using: - - git config hooks.allownonascii true -EOF - exit 1 -fi - -# If there are whitespace errors, print the offending file names and fail. -exec git diff-index --check --cached $against -- diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-push.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-push.sample deleted file mode 100755 index 6187dbf4390fc..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-push.sample +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -# An example hook script to verify what is about to be pushed. Called by "git -# push" after it has checked the remote status, but before anything has been -# pushed. If this script exits with a non-zero status nothing will be pushed. -# -# This hook is called with the following parameters: -# -# $1 -- Name of the remote to which the push is being done -# $2 -- URL to which the push is being done -# -# If pushing without using a named remote those arguments will be equal. -# -# Information about the commits which are being pushed is supplied as lines to -# the standard input in the form: -# -# -# -# This sample shows how to prevent push of commits where the log message starts -# with "WIP" (work in progress). - -remote="$1" -url="$2" - -z40=0000000000000000000000000000000000000000 - -while read local_ref local_sha remote_ref remote_sha -do - if [ "$local_sha" = $z40 ] - then - # Handle delete - : - else - if [ "$remote_sha" = $z40 ] - then - # New branch, examine all commits - range="$local_sha" - else - # Update to existing branch, examine new commits - range="$remote_sha..$local_sha" - fi - - # Check for WIP commit - commit=`git rev-list -n 1 --grep '^WIP' "$range"` - if [ -n "$commit" ] - then - echo >&2 "Found WIP commit in $local_ref, not pushing" - exit 1 - fi - fi -done - -exit 0 diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-rebase.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-rebase.sample deleted file mode 100755 index 33730ca647cb2..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-rebase.sample +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006, 2008 Junio C Hamano -# -# The "pre-rebase" hook is run just before "git rebase" starts doing -# its job, and can prevent the command from running by exiting with -# non-zero status. -# -# The hook is called with the following parameters: -# -# $1 -- the upstream the series was forked from. -# $2 -- the branch being rebased (or empty when rebasing the current branch). -# -# This sample shows how to prevent topic branches that are already -# merged to 'next' branch from getting rebased, because allowing it -# would result in rebasing already published history. - -publish=next -basebranch="$1" -if test "$#" = 2 -then - topic="refs/heads/$2" -else - topic=`git symbolic-ref HEAD` || - exit 0 ;# we do not interrupt rebasing detached HEAD -fi - -case "$topic" in -refs/heads/??/*) - ;; -*) - exit 0 ;# we do not interrupt others. - ;; -esac - -# Now we are dealing with a topic branch being rebased -# on top of master. Is it OK to rebase it? - -# Does the topic really exist? -git show-ref -q "$topic" || { - echo >&2 "No such branch $topic" - exit 1 -} - -# Is topic fully merged to master? -not_in_master=`git rev-list --pretty=oneline ^master "$topic"` -if test -z "$not_in_master" -then - echo >&2 "$topic is fully merged to master; better remove it." - exit 1 ;# we could allow it, but there is no point. -fi - -# Is topic ever merged to next? If so you should not be rebasing it. -only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` -only_next_2=`git rev-list ^master ${publish} | sort` -if test "$only_next_1" = "$only_next_2" -then - not_in_topic=`git rev-list "^$topic" master` - if test -z "$not_in_topic" - then - echo >&2 "$topic is already up-to-date with master" - exit 1 ;# we could allow it, but there is no point. - else - exit 0 - fi -else - not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` - /usr/bin/perl -e ' - my $topic = $ARGV[0]; - my $msg = "* $topic has commits already merged to public branch:\n"; - my (%not_in_next) = map { - /^([0-9a-f]+) /; - ($1 => 1); - } split(/\n/, $ARGV[1]); - for my $elem (map { - /^([0-9a-f]+) (.*)$/; - [$1 => $2]; - } split(/\n/, $ARGV[2])) { - if (!exists $not_in_next{$elem->[0]}) { - if ($msg) { - print STDERR $msg; - undef $msg; - } - print STDERR " $elem->[1]\n"; - } - } - ' "$topic" "$not_in_next" "$not_in_master" - exit 1 -fi - -<<\DOC_END - -This sample hook safeguards topic branches that have been -published from being rewound. - -The workflow assumed here is: - - * Once a topic branch forks from "master", "master" is never - merged into it again (either directly or indirectly). - - * Once a topic branch is fully cooked and merged into "master", - it is deleted. If you need to build on top of it to correct - earlier mistakes, a new topic branch is created by forking at - the tip of the "master". This is not strictly necessary, but - it makes it easier to keep your history simple. - - * Whenever you need to test or publish your changes to topic - branches, merge them into "next" branch. - -The script, being an example, hardcodes the publish branch name -to be "next", but it is trivial to make it configurable via -$GIT_DIR/config mechanism. - -With this workflow, you would want to know: - -(1) ... if a topic branch has ever been merged to "next". Young - topic branches can have stupid mistakes you would rather - clean up before publishing, and things that have not been - merged into other branches can be easily rebased without - affecting other people. But once it is published, you would - not want to rewind it. - -(2) ... if a topic branch has been fully merged to "master". - Then you can delete it. More importantly, you should not - build on top of it -- other people may already want to - change things related to the topic as patches against your - "master", so if you need further changes, it is better to - fork the topic (perhaps with the same name) afresh from the - tip of "master". - -Let's look at this example: - - o---o---o---o---o---o---o---o---o---o "next" - / / / / - / a---a---b A / / - / / / / - / / c---c---c---c B / - / / / \ / - / / / b---b C \ / - / / / / \ / - ---o---o---o---o---o---o---o---o---o---o---o "master" - - -A, B and C are topic branches. - - * A has one fix since it was merged up to "next". - - * B has finished. It has been fully merged up to "master" and "next", - and is ready to be deleted. - - * C has not merged to "next" at all. - -We would want to allow C to be rebased, refuse A, and encourage -B to be deleted. - -To compute (1): - - git rev-list ^master ^topic next - git rev-list ^master next - - if these match, topic has not merged in next at all. - -To compute (2): - - git rev-list master..topic - - if this is empty, it is fully merged to "master". - -DOC_END diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive deleted file mode 100755 index 412701305369c..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -ORI_DIR=`pwd` -SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) -cd "$ORI_DIR" -for i in `ls "$SHELL_FOLDER/pre-receive.d"`; do - sh "$SHELL_FOLDER/pre-receive.d/$i" -done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive.d/gitea b/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive.d/gitea deleted file mode 100755 index 49d09406364a5..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/pre-receive.d/gitea +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" pre-receive diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/prepare-commit-msg.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/prepare-commit-msg.sample deleted file mode 100755 index f093a02ec4991..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/prepare-commit-msg.sample +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare the commit log message. -# Called by "git commit" with the name of the file that has the -# commit message, followed by the description of the commit -# message's source. The hook's purpose is to edit the commit -# message file. If the hook fails with a non-zero status, -# the commit is aborted. -# -# To enable this hook, rename this file to "prepare-commit-msg". - -# This hook includes three examples. The first comments out the -# "Conflicts:" part of a merge commit. -# -# The second includes the output of "git diff --name-status -r" -# into the message, just before the "git status" output. It is -# commented because it doesn't cope with --amend or with squashed -# commits. -# -# The third example adds a Signed-off-by line to the message, that can -# still be edited. This is rarely a good idea. - -case "$2,$3" in - merge,) - /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; - -# ,|template,) -# /usr/bin/perl -i.bak -pe ' -# print "\n" . `git diff --cached --name-status -r` -# if /^#/ && $first++ == 0' "$1" ;; - - *) ;; -esac - -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/update b/integrations/gitea-repositories-meta/user2/golang.git/hooks/update deleted file mode 100755 index c186fe4a18b0f..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/update +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -ORI_DIR=`pwd` -SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) -cd "$ORI_DIR" -for i in `ls "$SHELL_FOLDER/update.d"`; do - sh "$SHELL_FOLDER/update.d/$i" $1 $2 $3 -done \ No newline at end of file diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.d/gitea b/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.d/gitea deleted file mode 100755 index 38101c242664a..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.d/gitea +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" update $1 $2 $3 diff --git a/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.sample b/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.sample deleted file mode 100755 index 80ba94135cc37..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/hooks/update.sample +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/sh -# -# An example hook script to block unannotated tags from entering. -# Called by "git receive-pack" with arguments: refname sha1-old sha1-new -# -# To enable this hook, rename this file to "update". -# -# Config -# ------ -# hooks.allowunannotated -# This boolean sets whether unannotated tags will be allowed into the -# repository. By default they won't be. -# hooks.allowdeletetag -# This boolean sets whether deleting tags will be allowed in the -# repository. By default they won't be. -# hooks.allowmodifytag -# This boolean sets whether a tag may be modified after creation. By default -# it won't be. -# hooks.allowdeletebranch -# This boolean sets whether deleting branches will be allowed in the -# repository. By default they won't be. -# hooks.denycreatebranch -# This boolean sets whether remotely creating branches will be denied -# in the repository. By default this is allowed. -# - -# --- Command line -refname="$1" -oldrev="$2" -newrev="$3" - -# --- Safety check -if [ -z "$GIT_DIR" ]; then - echo "Don't run this script from the command line." >&2 - echo " (if you want, you could supply GIT_DIR then run" >&2 - echo " $0 )" >&2 - exit 1 -fi - -if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then - echo "usage: $0 " >&2 - exit 1 -fi - -# --- Config -allowunannotated=$(git config --bool hooks.allowunannotated) -allowdeletebranch=$(git config --bool hooks.allowdeletebranch) -denycreatebranch=$(git config --bool hooks.denycreatebranch) -allowdeletetag=$(git config --bool hooks.allowdeletetag) -allowmodifytag=$(git config --bool hooks.allowmodifytag) - -# check for no description -projectdesc=$(sed -e '1q' "$GIT_DIR/description") -case "$projectdesc" in -"Unnamed repository"* | "") - echo "*** Project description file hasn't been set" >&2 - exit 1 - ;; -esac - -# --- Check types -# if $newrev is 0000...0000, it's a commit to delete a ref. -zero="0000000000000000000000000000000000000000" -if [ "$newrev" = "$zero" ]; then - newrev_type=delete -else - newrev_type=$(git cat-file -t $newrev) -fi - -case "$refname","$newrev_type" in - refs/tags/*,commit) - # un-annotated tag - short_refname=${refname##refs/tags/} - if [ "$allowunannotated" != "true" ]; then - echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 - echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 - exit 1 - fi - ;; - refs/tags/*,delete) - # delete tag - if [ "$allowdeletetag" != "true" ]; then - echo "*** Deleting a tag is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/tags/*,tag) - # annotated tag - if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 - then - echo "*** Tag '$refname' already exists." >&2 - echo "*** Modifying a tag is not allowed in this repository." >&2 - exit 1 - fi - ;; - refs/heads/*,commit) - # branch - if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then - echo "*** Creating a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/heads/*,delete) - # delete branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/remotes/*,commit) - # tracking branch - ;; - refs/remotes/*,delete) - # delete tracking branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a tracking branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - *) - # Anything else (is there anything else?) - echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 - exit 1 - ;; -esac - -# --- Finished -exit 0 diff --git a/integrations/gitea-repositories-meta/user2/golang.git/info/exclude b/integrations/gitea-repositories-meta/user2/golang.git/info/exclude deleted file mode 100644 index a5196d1be8fb5..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/info/exclude +++ /dev/null @@ -1,6 +0,0 @@ -# git ls-files --others --exclude-from=.git/info/exclude -# Lines that start with '#' are comments. -# For a project mostly in C, the following would be a good set of -# exclude patterns (uncomment them if you want to use them): -# *.[oa] -# *~ diff --git a/integrations/gitea-repositories-meta/user2/golang.git/info/refs b/integrations/gitea-repositories-meta/user2/golang.git/info/refs deleted file mode 100644 index ca1df85e2ebfb..0000000000000 --- a/integrations/gitea-repositories-meta/user2/golang.git/info/refs +++ /dev/null @@ -1 +0,0 @@ -65f1bf27bc3bf70f64657658635e66094edbcb4d refs/heads/master diff --git a/integrations/gitea-repositories-meta/user2/golang.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 b/integrations/gitea-repositories-meta/user2/golang.git/objects/2a/2f1d4670728a2e10049e345bd7a276468beab6 deleted file mode 100644 index 0994add2c8a420ba89b9a239de84741d4d00ee02..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmV-60LlM&0V^p=O;s>9XD~D{Ff%bx2y%6F@paY9O=0l%2wWR@KdW}W>d8uz$jVo* MqfO=m05RYX?j~gyApigX diff --git a/integrations/gitea-repositories-meta/user2/golang.git/objects/4b/4851ad51df6a7d9f25c979345979eaeb5b349f b/integrations/gitea-repositories-meta/user2/golang.git/objects/4b/4851ad51df6a7d9f25c979345979eaeb5b349f deleted file mode 100644 index 700a13828e63248a392e4c90d92bbb6e3dd57ba0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 42 ycmb%v7rOCc0q7S-{K(sSa& zkkbhiI`12U*27++lwz~nt#W~Lz0(ZW%yS%} Date: Tue, 31 Jul 2018 15:03:43 +0800 Subject: [PATCH 11/21] fix: testing topic --- models/topic_test.go | 6 +++--- models/user_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/models/topic_test.go b/models/topic_test.go index ef374e557bba0..65e52afb12f6c 100644 --- a/models/topic_test.go +++ b/models/topic_test.go @@ -15,7 +15,7 @@ func TestAddTopic(t *testing.T) { topics, err := FindTopics(&FindTopicOptions{}) assert.NoError(t, err) - assert.EqualValues(t, 3, len(topics)) + assert.EqualValues(t, 4, len(topics)) topics, err = FindTopics(&FindTopicOptions{ Limit: 2, @@ -32,7 +32,7 @@ func TestAddTopic(t *testing.T) { assert.NoError(t, SaveTopics(2, "golang")) topics, err = FindTopics(&FindTopicOptions{}) assert.NoError(t, err) - assert.EqualValues(t, 3, len(topics)) + assert.EqualValues(t, 4, len(topics)) topics, err = FindTopics(&FindTopicOptions{ RepoID: 2, @@ -47,7 +47,7 @@ func TestAddTopic(t *testing.T) { topics, err = FindTopics(&FindTopicOptions{}) assert.NoError(t, err) - assert.EqualValues(t, 4, len(topics)) + assert.EqualValues(t, 5, len(topics)) topics, err = FindTopics(&FindTopicOptions{ RepoID: 2, diff --git a/models/user_test.go b/models/user_test.go index 20de1a64be504..4713b6864c45f 100644 --- a/models/user_test.go +++ b/models/user_test.go @@ -77,13 +77,13 @@ func TestSearchUsers(t *testing.T) { } testUserSuccess(&SearchUserOptions{OrderBy: "id ASC", Page: 1}, - []int64{1, 2, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20}) + []int64{1, 2, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21}) testUserSuccess(&SearchUserOptions{Page: 1, IsActive: util.OptionalBoolFalse}, []int64{9}) testUserSuccess(&SearchUserOptions{OrderBy: "id ASC", Page: 1, IsActive: util.OptionalBoolTrue}, - []int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20}) + []int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21}) testUserSuccess(&SearchUserOptions{Keyword: "user1", OrderBy: "id ASC", Page: 1, IsActive: util.OptionalBoolTrue}, []int64{1, 10, 11, 12, 13, 14, 15, 16, 18}) From ea760a13e48c98b6d2a7428ce1b5a00606e58b68 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 31 Jul 2018 15:08:26 +0800 Subject: [PATCH 12/21] fix: intergration testing --- integrations/api_repo_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go index 3f3ffb63c0703..3fa2ae21dc03e 100644 --- a/integrations/api_repo_test.go +++ b/integrations/api_repo_test.go @@ -67,9 +67,9 @@ func TestAPISearchRepo(t *testing.T) { expectedResults }{ {name: "RepositoriesMax50", requestURL: "/api/v1/repos/search?limit=50", expectedResults: expectedResults{ - nil: {count: 16}, - user: {count: 16}, - user2: {count: 16}}, + nil: {count: 17}, + user: {count: 17}, + user2: {count: 17}}, }, {name: "RepositoriesMax10", requestURL: "/api/v1/repos/search?limit=10", expectedResults: expectedResults{ nil: {count: 10}, From 612815d76d67def20e09145c4c00dfc0ac2f75fc Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 31 Jul 2018 15:16:58 +0800 Subject: [PATCH 13/21] fix: intergration testing --- integrations/api_repo_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go index 3fa2ae21dc03e..5ef60fc8f1c73 100644 --- a/integrations/api_repo_test.go +++ b/integrations/api_repo_test.go @@ -67,9 +67,9 @@ func TestAPISearchRepo(t *testing.T) { expectedResults }{ {name: "RepositoriesMax50", requestURL: "/api/v1/repos/search?limit=50", expectedResults: expectedResults{ - nil: {count: 17}, - user: {count: 17}, - user2: {count: 17}}, + nil: {count: 18}, + user: {count: 18}, + user2: {count: 18}}, }, {name: "RepositoriesMax10", requestURL: "/api/v1/repos/search?limit=10", expectedResults: expectedResults{ nil: {count: 10}, From 769e8adb24b54749d0dbe14d57fa9421435dc559 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 3 Aug 2018 12:00:06 +0800 Subject: [PATCH 14/21] fix: rename Topic to TopicOnly --- models/repo_list.go | 4 ++-- routers/api/v1/repo/repo.go | 2 +- routers/home.go | 4 ++-- routers/user/profile.go | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/models/repo_list.go b/models/repo_list.go index eb9a2269dcc1e..c7e292d8a9eab 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -132,7 +132,7 @@ type SearchRepoOptions struct { // False -> include just non-mirrors Mirror util.OptionalBool // only search topic name - Topic bool + TopicOnly bool } //SearchOrderBy is used to sort the result @@ -205,7 +205,7 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, err if opts.Keyword != "" { var keywordCond = builder.NewCond() - if opts.Topic { + if opts.TopicOnly { keywordCond = keywordCond.Or(builder.Like{"topic.name", strings.ToLower(opts.Keyword)}) } else { keywordCond = keywordCond.Or(builder.Like{"lower_name", strings.ToLower(opts.Keyword)}) diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index d0fa4a02e7c9f..e48b100af61cb 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -91,7 +91,7 @@ func Search(ctx *context.APIContext) { OwnerID: ctx.QueryInt64("uid"), Page: ctx.QueryInt("page"), PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")), - Topic: ctx.QueryBool("topic"), + TopicOnly: ctx.QueryBool("topic"), Collaborate: util.OptionalBoolNone, } diff --git a/routers/home.go b/routers/home.go index d9a118cad0367..7a23e8765e016 100644 --- a/routers/home.go +++ b/routers/home.go @@ -122,7 +122,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { } keyword := strings.Trim(ctx.Query("q"), " ") - topic := ctx.QueryBool("topic") + topicOnly := ctx.QueryBool("topic") repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{ Page: page, @@ -132,7 +132,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { Keyword: keyword, OwnerID: opts.OwnerID, AllPublic: true, - Topic: topic, + TopicOnly: topicOnly, }) if err != nil { ctx.ServerError("SearchRepositoryByName", err) diff --git a/routers/user/profile.go b/routers/user/profile.go index 974244941f7cc..827226d3e101c 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -105,7 +105,7 @@ func Profile(ctx *context.Context) { page = 1 } - topic := ctx.QueryBool("topic") + topicOnly := ctx.QueryBool("topic") var ( repos []*models.Repository @@ -176,7 +176,7 @@ func Profile(ctx *context.Context) { PageSize: setting.UI.User.RepoPagingNum, Starred: true, Collaborate: util.OptionalBoolFalse, - Topic: topic, + TopicOnly: topicOnly, }) if err != nil { ctx.ServerError("SearchRepositoryByName", err) @@ -220,7 +220,7 @@ func Profile(ctx *context.Context) { IsProfile: true, PageSize: setting.UI.User.RepoPagingNum, Collaborate: util.OptionalBoolFalse, - Topic: topic, + TopicOnly: topicOnly, }) if err != nil { ctx.ServerError("SearchRepositoryByName", err) From 229ea261046a6f44e8c899618557a773294d34ed Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 3 Aug 2018 12:06:04 +0800 Subject: [PATCH 15/21] test: fix --- models/repo_list_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/repo_list_test.go b/models/repo_list_test.go index 6cb62f45d324d..678fd930fbeb4 100644 --- a/models/repo_list_test.go +++ b/models/repo_list_test.go @@ -235,7 +235,7 @@ func TestSearchRepositoryByTopicName(t *testing.T) { opts: &SearchRepoOptions{OwnerID: 21, AllPublic: true, Keyword: "graphql"}, count: 2}, {name: "AllPublic/OnlySearchPublicRepositoriesFromTopic", - opts: &SearchRepoOptions{OwnerID: 21, AllPublic: true, Keyword: "graphql", Topic: true}, + opts: &SearchRepoOptions{OwnerID: 21, AllPublic: true, Keyword: "graphql", TopicOnly: true}, count: 1}, } From f0a4d2ad75b2de18d8e5abee3d50c74eac7eec8d Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 13 Sep 2018 00:13:35 +0800 Subject: [PATCH 16/21] update repo name Signed-off-by: Bo-Yi Wu --- models/fixtures/repository.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index 166f380d74e86..27b0364fd781c 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -404,8 +404,8 @@ - id: 33 owner_id: 21 - lower_name: golang - name: golang + lower_name: utf8 + name: utf8 is_private: false num_stars: 0 num_forks: 0 From a87f5e7ec67245bed524116de05fdad2c2aa652f Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 13 Sep 2018 08:58:36 +0800 Subject: [PATCH 17/21] fix package order. Signed-off-by: Bo-Yi Wu --- integrations/api_admin_test.go | 4 ++-- integrations/api_issue_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/integrations/api_admin_test.go b/integrations/api_admin_test.go index f801b08d39e4b..690edad757a64 100644 --- a/integrations/api_admin_test.go +++ b/integrations/api_admin_test.go @@ -9,10 +9,10 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/assert" - "code.gitea.io/gitea/models" api "code.gitea.io/sdk/gitea" + + "github.com/stretchr/testify/assert" ) func TestAPIAdminCreateAndDeleteSSHKey(t *testing.T) { diff --git a/integrations/api_issue_test.go b/integrations/api_issue_test.go index 97207f3368e1b..0ac2f3b67e9b0 100644 --- a/integrations/api_issue_test.go +++ b/integrations/api_issue_test.go @@ -5,13 +5,13 @@ package integrations import ( + "fmt" "net/http" "testing" "code.gitea.io/gitea/models" api "code.gitea.io/sdk/gitea" - "fmt" "github.com/stretchr/testify/assert" ) From 2ab214d15dd7f8ce8984d0b918dfb40a93b4fe4c Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 13 Sep 2018 09:14:59 +0800 Subject: [PATCH 18/21] fix: repo yaml --- models/fixtures/repository.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index 27b0364fd781c..c2987b9658678 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -403,17 +403,24 @@ - id: 33 - owner_id: 21 + owner_id: 2 lower_name: utf8 name: utf8 is_private: false + +- + id: 34 + owner_id: 21 + lower_name: golang + name: golang + is_private: false num_stars: 0 num_forks: 0 num_issues: 0 is_mirror: false - - id: 34 + id: 35 owner_id: 21 lower_name: graphql name: graphql From 9cdaf74d6d56a3cb0417515ca46a8fc3aed61a7a Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 13 Sep 2018 09:29:46 +0800 Subject: [PATCH 19/21] fix: update repo count --- models/fixtures/user.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/fixtures/user.yml b/models/fixtures/user.yml index 2d22c00715381..b3850e35991c1 100644 --- a/models/fixtures/user.yml +++ b/models/fixtures/user.yml @@ -27,7 +27,7 @@ is_admin: false avatar: avatar2 avatar_email: user2@example.com - num_repos: 5 + num_repos: 6 num_stars: 2 num_followers: 2 num_following: 1 From 199d237e78303e71fcd2d0e8360a23e36deff5a5 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 13 Sep 2018 09:38:46 +0800 Subject: [PATCH 20/21] fix repo count Signed-off-by: Bo-Yi Wu --- models/repo_list_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/repo_list_test.go b/models/repo_list_test.go index 678fd930fbeb4..8f4947dbb22cb 100644 --- a/models/repo_list_test.go +++ b/models/repo_list_test.go @@ -147,10 +147,10 @@ func TestSearchRepositoryByName(t *testing.T) { count: 14}, {name: "AllPublic/PublicRepositoriesOfUserIncludingCollaborative", opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, AllPublic: true}, - count: 18}, + count: 19}, {name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborative", opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true}, - count: 22}, + count: 23}, {name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborativeByName", opts: &SearchRepoOptions{Keyword: "test", Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true}, count: 13}, @@ -159,7 +159,7 @@ func TestSearchRepositoryByName(t *testing.T) { count: 11}, {name: "AllPublic/PublicRepositoriesOfOrganization", opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 17, AllPublic: true, Collaborate: util.OptionalBoolFalse}, - count: 18}, + count: 19}, } for _, testCase := range testCases { From e50d8e794445eecf7b6d1b95ca94de5a49cc7e78 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 13 Sep 2018 10:25:06 +0800 Subject: [PATCH 21/21] fix repo count Signed-off-by: Bo-Yi Wu --- integrations/api_repo_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go index 5ef60fc8f1c73..62237e2be3c8d 100644 --- a/integrations/api_repo_test.go +++ b/integrations/api_repo_test.go @@ -67,9 +67,9 @@ func TestAPISearchRepo(t *testing.T) { expectedResults }{ {name: "RepositoriesMax50", requestURL: "/api/v1/repos/search?limit=50", expectedResults: expectedResults{ - nil: {count: 18}, - user: {count: 18}, - user2: {count: 18}}, + nil: {count: 19}, + user: {count: 19}, + user2: {count: 19}}, }, {name: "RepositoriesMax10", requestURL: "/api/v1/repos/search?limit=10", expectedResults: expectedResults{ nil: {count: 10},