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

Add tests for commit count on releases page #24157

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions models/fixtures/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
base_repo_id: 1
head_branch: branch1
base_branch: master
merge_base: 4a357436d925b5c974181ff12a994538ddc5a269
merge_base: 40587f82e2bae1309157cef04b91da7e96a7ed20
has_merged: true
merger_id: 2

Expand All @@ -22,7 +22,7 @@
base_repo_id: 1
head_branch: branch2
base_branch: master
merge_base: 4a357436d925b5c974181ff12a994538ddc5a269
merge_base: 40587f82e2bae1309157cef04b91da7e96a7ed20
has_merged: false

-
Expand Down Expand Up @@ -61,7 +61,7 @@
base_repo_id: 1
head_branch: pr-to-update
base_branch: branch2
merge_base: 985f0301dba5e7b34be866819cd15ad3d8f508ee
merge_base: a270587a5cf3bcfa12c4c58f771ff58ee9694f43
has_merged: false

-
Expand Down
28 changes: 21 additions & 7 deletions models/fixtures/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
lower_tag_name: "v1.1"
target: "master"
title: "testing-release"
sha1: "65f1bf27bc3bf70f64657658635e66094edbcb4d"
num_commits: 10
sha1: "0d653ed2b0d85ea39fefc1c193bf49c09eaac731"
num_commits: 3
is_draft: false
is_prerelease: false
is_tag: false
Expand All @@ -19,8 +19,8 @@
lower_tag_name: "v1.1"
target: "master"
title: "testing-release"
sha1: "65f1bf27bc3bf70f64657658635e66094edbcb4d"
num_commits: 10
sha1: "0d653ed2b0d85ea39fefc1c193bf49c09eaac731"
num_commits: 3
is_draft: false
is_prerelease: false
is_tag: false
Expand All @@ -33,7 +33,7 @@
lower_tag_name: "delete-tag"
target: "master"
title: "delete-tag"
sha1: "65f1bf27bc3bf70f64657658635e66094edbcb4d"
sha1: "0d653ed2b0d85ea39fefc1c193bf49c09eaac731"
num_commits: 10
is_draft: false
is_prerelease: false
Expand All @@ -60,9 +60,23 @@
target: "master"
title: "pre-release"
note: "some text for a pre release"
sha1: "65f1bf27bc3bf70f64657658635e66094edbcb4d"
sha1: "2f58a0d23e6e6bc235613f0d53482298a0862fac"
num_commits: 1
is_draft: false
is_prerelease: true
is_tag: false
created_unix: 946684800
created_unix: 946684700 # before v1.1

- id: 6
repo_id: 1
publisher_id: 2
tag_name: "v0.1"
lower_tag_name: "v0.1"
target: "master"
title: "initial"
sha1: "2f58a0d23e6e6bc235613f0d53482298a0862fac"
num_commits: 1
is_draft: false
is_prerelease: false
is_tag: false
created_unix: 946684600 # before v1.0
2 changes: 1 addition & 1 deletion modules/indexer/stats/indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestRepoStatsIndex(t *testing.T) {

status, err := repo_model.GetIndexerStatus(db.DefaultContext, repo, repo_model.RepoIndexerTypeStats)
assert.NoError(t, err)
assert.Equal(t, "65f1bf27bc3bf70f64657658635e66094edbcb4d", status.CommitSha)
assert.Equal(t, "0d653ed2b0d85ea39fefc1c193bf49c09eaac731", status.CommitSha)
langs, err := repo_model.GetTopLanguageStats(repo, 5)
assert.NoError(t, err)
assert.Empty(t, langs)
Expand Down
26 changes: 13 additions & 13 deletions modules/markup/html_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestRender_Commits(t *testing.T) {
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
}

sha := "65f1bf27bc3bf70f64657658635e66094edbcb4d"
sha := "0d653ed2b0d85ea39fefc1c193bf49c09eaac731"
repo := TestRepoURL
commit := util.URLJoin(repo, "commit", sha)
tree := util.URLJoin(repo, "tree", sha, "src")
Expand All @@ -61,20 +61,20 @@ func TestRender_Commits(t *testing.T) {
commitCompare := util.URLJoin(repo, "compare", sha+"..."+sha)
commitCompareWithHash := commitCompare + "#L2"

test(sha, `<p><a href="`+commit+`" rel="nofollow"><code>65f1bf27bc</code></a></p>`)
test(sha[:7], `<p><a href="`+commit[:len(commit)-(40-7)]+`" rel="nofollow"><code>65f1bf2</code></a></p>`)
test(sha[:39], `<p><a href="`+commit[:len(commit)-(40-39)]+`" rel="nofollow"><code>65f1bf27bc</code></a></p>`)
test(commit, `<p><a href="`+commit+`" rel="nofollow"><code>65f1bf27bc</code></a></p>`)
test(tree, `<p><a href="`+tree+`" rel="nofollow"><code>65f1bf27bc/src</code></a></p>`)
test(sha, `<p><a href="`+commit+`" rel="nofollow"><code>0d653ed7bc</code></a></p>`)
test(sha[:7], `<p><a href="`+commit[:len(commit)-(40-7)]+`" rel="nofollow"><code>0d653ed</code></a></p>`)
test(sha[:39], `<p><a href="`+commit[:len(commit)-(40-39)]+`" rel="nofollow"><code>0d653ed7bc</code></a></p>`)
test(commit, `<p><a href="`+commit+`" rel="nofollow"><code>0d653ed7bc</code></a></p>`)
test(tree, `<p><a href="`+tree+`" rel="nofollow"><code>0d653ed7bc/src</code></a></p>`)

test(file, `<p><a href="`+file+`" rel="nofollow"><code>65f1bf27bc/example.txt</code></a></p>`)
test(fileWithExtra, `<p><a href="`+file+`" rel="nofollow"><code>65f1bf27bc/example.txt</code></a>:</p>`)
test(fileWithHash, `<p><a href="`+fileWithHash+`" rel="nofollow"><code>65f1bf27bc/example.txt (L2)</code></a></p>`)
test(fileWithHasExtra, `<p><a href="`+fileWithHash+`" rel="nofollow"><code>65f1bf27bc/example.txt (L2)</code></a>:</p>`)
test(commitCompare, `<p><a href="`+commitCompare+`" rel="nofollow"><code>65f1bf27bc...65f1bf27bc</code></a></p>`)
test(commitCompareWithHash, `<p><a href="`+commitCompareWithHash+`" rel="nofollow"><code>65f1bf27bc...65f1bf27bc (L2)</code></a></p>`)
test(file, `<p><a href="`+file+`" rel="nofollow"><code>0d653ed7bc/example.txt</code></a></p>`)
test(fileWithExtra, `<p><a href="`+file+`" rel="nofollow"><code>0d653ed7bc/example.txt</code></a>:</p>`)
test(fileWithHash, `<p><a href="`+fileWithHash+`" rel="nofollow"><code>0d653ed7bc/example.txt (L2)</code></a></p>`)
test(fileWithHasExtra, `<p><a href="`+fileWithHash+`" rel="nofollow"><code>0d653ed7bc/example.txt (L2)</code></a>:</p>`)
test(commitCompare, `<p><a href="`+commitCompare+`" rel="nofollow"><code>0d653ed7bc...0d653ed7bc</code></a></p>`)
test(commitCompareWithHash, `<p><a href="`+commitCompareWithHash+`" rel="nofollow"><code>0d653ed7bc...0d653ed7bc (L2)</code></a></p>`)

test("commit "+sha, `<p>commit <a href="`+commit+`" rel="nofollow"><code>65f1bf27bc</code></a></p>`)
test("commit "+sha, `<p>commit <a href="`+commit+`" rel="nofollow"><code>0d653ed7bc</code></a></p>`)
test("/home/gitea/"+sha, "<p>/home/gitea/"+sha+"</p>")
test("deadbeef", `<p>deadbeef</p>`)
test("d27ace93", `<p>d27ace93</p>`)
Expand Down
4 changes: 2 additions & 2 deletions modules/markup/markdown/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
<li><a href="` + baseURLContent + `/Links" rel="nofollow">Links, Language bindings, Engine bindings</a></li>
<li><a href="` + baseURLContent + `/Tips" rel="nofollow">Tips</a></li>
</ul>
<p>See commit <a href="http://localhost:3000/gogits/gogs/commit/65f1bf27bc" rel="nofollow"><code>65f1bf27bc</code></a></p>
<p>See commit <a href="http://localhost:3000/gogits/gogs/commit/0d653ed7bc" rel="nofollow"><code>0d653ed7bc</code></a></p>
<p>Ideas and codes</p>
<ul>
<li>Bezier widget (by <a href="` + AppURL + `r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="http://localhost:3000/ocornut/imgui/issues/786" class="ref-issue" rel="nofollow">ocornut/imgui#786</a></li>
Expand Down Expand Up @@ -211,7 +211,7 @@ var sameCases = []string{
- [[Links, Language bindings, Engine bindings|Links]]
- [[Tips]]

See commit 65f1bf27bc
See commit 0d653ed7bc

Ideas and codes

Expand Down
2 changes: 1 addition & 1 deletion services/convert/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestPullRequest_APIFormat(t *testing.T) {
assert.EqualValues(t, &structs.PRBranchInfo{
Name: "branch1",
Ref: "refs/pull/2/head",
Sha: "4a357436d925b5c974181ff12a994538ddc5a269",
Sha: "40587f82e2bae1309157cef04b91da7e96a7ed20",
RepoID: 1,
Repository: ToRepo(db.DefaultContext, headRepo, perm.AccessModeRead),
}, apiPullRequest.Head)
Expand Down
18 changes: 9 additions & 9 deletions services/release/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestRelease_Create(t *testing.T) {
PublisherID: user.ID,
Publisher: user,
TagName: "v0.1.1",
Target: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
Target: "0d653ed2b0d85ea39fefc1c193bf49c09eaac731",
Title: "v0.1.1 is released",
Note: "v0.1.1 is released",
IsDraft: false,
Expand All @@ -70,7 +70,7 @@ func TestRelease_Create(t *testing.T) {
PublisherID: user.ID,
Publisher: user,
TagName: "v0.1.2",
Target: "65f1bf2",
Target: "0d653ed",
Title: "v0.1.2 is released",
Note: "v0.1.2 is released",
IsDraft: false,
Expand All @@ -84,7 +84,7 @@ func TestRelease_Create(t *testing.T) {
PublisherID: user.ID,
Publisher: user,
TagName: "v0.1.3",
Target: "65f1bf2",
Target: "0d653ed",
Title: "v0.1.3 is released",
Note: "v0.1.3 is released",
IsDraft: true,
Expand All @@ -98,7 +98,7 @@ func TestRelease_Create(t *testing.T) {
PublisherID: user.ID,
Publisher: user,
TagName: "v0.1.4",
Target: "65f1bf2",
Target: "0d653ed",
Title: "v0.1.4 is released",
Note: "v0.1.4 is released",
IsDraft: false,
Expand All @@ -121,7 +121,7 @@ func TestRelease_Create(t *testing.T) {
PublisherID: user.ID,
Publisher: user,
TagName: "v0.1.5",
Target: "65f1bf2",
Target: "0d653ed",
Title: "v0.1.5 is released",
Note: "v0.1.5 is released",
IsDraft: false,
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestRelease_Update(t *testing.T) {
PublisherID: user.ID,
Publisher: user,
TagName: "v1.2.1",
Target: "65f1bf2",
Target: "0d653ed",
Title: "v1.2.1 is draft",
Note: "v1.2.1 is draft",
IsDraft: true,
Expand All @@ -197,7 +197,7 @@ func TestRelease_Update(t *testing.T) {
PublisherID: user.ID,
Publisher: user,
TagName: "v1.3.1",
Target: "65f1bf2",
Target: "0d653ed",
Title: "v1.3.1 is pre-released",
Note: "v1.3.1 is pre-released",
IsDraft: false,
Expand Down Expand Up @@ -316,7 +316,7 @@ func TestRelease_createTag(t *testing.T) {
PublisherID: user.ID,
Publisher: user,
TagName: "v2.2.1",
Target: "65f1bf2",
Target: "0d653ed",
Title: "v2.2.1 is draft",
Note: "v2.2.1 is draft",
IsDraft: true,
Expand All @@ -339,7 +339,7 @@ func TestRelease_createTag(t *testing.T) {
PublisherID: user.ID,
Publisher: user,
TagName: "v2.3.1",
Target: "65f1bf2",
Target: "0d653ed",
Title: "v2.3.1 is pre-released",
Note: "v2.3.1 is pre-released",
IsDraft: false,
Expand Down
8 changes: 4 additions & 4 deletions services/repository/files/content_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func getExpectedReadmeContentsResponse() *api.ContentsResponse {
Name: treePath,
Path: treePath,
SHA: "4b4851ad51df6a7d9f25c979345979eaeb5b349f",
LastCommitSHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
LastCommitSHA: "0d653ed2b0d85ea39fefc1c193bf49c09eaac731",
Type: "file",
Size: 30,
Encoding: &encoding,
Expand Down Expand Up @@ -232,7 +232,7 @@ func TestGetBlobBySHA(t *testing.T) {
test.LoadGitRepo(t, ctx)
defer ctx.Repo.GitRepo.Close()

sha := "65f1bf27bc3bf70f64657658635e66094edbcb4d"
sha := "0d653ed2b0d85ea39fefc1c193bf49c09eaac731"
ctx.SetParams(":id", "1")
ctx.SetParams(":sha", sha)

Expand All @@ -245,8 +245,8 @@ func TestGetBlobBySHA(t *testing.T) {
expectedGBR := &api.GitBlobResponse{
Content: "dHJlZSAyYTJmMWQ0NjcwNzI4YTJlMTAwNDllMzQ1YmQ3YTI3NjQ2OGJlYWI2CmF1dGhvciB1c2VyMSA8YWRkcmVzczFAZXhhbXBsZS5jb20+IDE0ODk5NTY0NzkgLTA0MDAKY29tbWl0dGVyIEV0aGFuIEtvZW5pZyA8ZXRoYW50a29lbmlnQGdtYWlsLmNvbT4gMTQ4OTk1NjQ3OSAtMDQwMAoKSW5pdGlhbCBjb21taXQK",
Encoding: "base64",
URL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/65f1bf27bc3bf70f64657658635e66094edbcb4d",
SHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
URL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/0d653ed2b0d85ea39fefc1c193bf49c09eaac731",
SHA: "0d653ed2b0d85ea39fefc1c193bf49c09eaac731",
Size: 180,
}
assert.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions services/repository/files/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func getExpectedFileResponse() *api.FileResponse {
Name: treePath,
Path: treePath,
SHA: sha,
LastCommitSHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
LastCommitSHA: "0d653ed2b0d85ea39fefc1c193bf49c09eaac731",
Type: "file",
Size: 30,
Encoding: &encoding,
Expand All @@ -62,10 +62,10 @@ func getExpectedFileResponse() *api.FileResponse {
},
Commit: &api.FileCommitResponse{
CommitMeta: api.CommitMeta{
URL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/commits/65f1bf27bc3bf70f64657658635e66094edbcb4d",
SHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
URL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/commits/0d653ed2b0d85ea39fefc1c193bf49c09eaac731",
SHA: "0d653ed2b0d85ea39fefc1c193bf49c09eaac731",
},
HTMLURL: "https://try.gitea.io/user2/repo1/commit/65f1bf27bc3bf70f64657658635e66094edbcb4d",
HTMLURL: "https://try.gitea.io/user2/repo1/commit/0d653ed2b0d85ea39fefc1c193bf49c09eaac731",
Author: &api.CommitUser{
Identity: api.Identity{
Name: "user1",
Expand Down
4 changes: 2 additions & 2 deletions services/repository/files/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func TestGetTreeBySHA(t *testing.T) {
tree, err := GetTreeBySHA(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Params(":sha"), page, perPage, true)
assert.NoError(t, err)
expectedTree := &api.GitTreeResponse{
SHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
URL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/trees/65f1bf27bc3bf70f64657658635e66094edbcb4d",
SHA: "0d653ed2b0d85ea39fefc1c193bf49c09eaac731",
URL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/trees/0d653ed2b0d85ea39fefc1c193bf49c09eaac731",
Entries: []api.GitEntry{
{
Path: "README.md",
Expand Down
17 changes: 14 additions & 3 deletions tests/gitea-repositories-meta/user2/repo1.git/info/refs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
65f1bf27bc3bf70f64657658635e66094edbcb4d refs/heads/master
985f0301dba5e7b34be866819cd15ad3d8f508ee refs/heads/branch2
62fb502a7172d4453f0322a2cc85bddffa57f07a refs/heads/pr-to-update
0d653ed2b0d85ea39fefc1c193bf49c09eaac731 refs/heads/DefaultBranch
a270587a5cf3bcfa12c4c58f771ff58ee9694f43 refs/heads/branch2
0d653ed2b0d85ea39fefc1c193bf49c09eaac731 refs/heads/develop
0d653ed2b0d85ea39fefc1c193bf49c09eaac731 refs/heads/feature/1
448e82b9e44d980faeddf37c7a266eca00f8b8f5 refs/heads/home-md-img-check
0d653ed2b0d85ea39fefc1c193bf49c09eaac731 refs/heads/master
208f14c1297434afedbdd620102056999be5caf0 refs/heads/pr-to-update
46a25bce2a8312552689901abf21d32b0c3a794b refs/heads/sub-home-md-img-check
3fa2f829675543ecfc16b2891aebe8bf0608a8f4 refs/notes/commits
40587f82e2bae1309157cef04b91da7e96a7ed20 refs/pull/2/head
eee617916f575706143a8f5b76ce66d34840708a refs/pull/3/head
208f14c1297434afedbdd620102056999be5caf0 refs/pull/5/head
2f58a0d23e6e6bc235613f0d53482298a0862fac refs/tags/v0.1
0d653ed2b0d85ea39fefc1c193bf49c09eaac731 refs/tags/v1.1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x��j�0 �{�S�^V������K�@��6����-}���\f�c&���:��_zSɁ��8����mV�]1��䦏V�B*�j%.ʔ����ťl�2�@h�ٿk����"M� ���ǹ�����H.$G�j��hǻ���h;k������޴Mga�J���.z7�y��}�}|���D�
Expand Down

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
P pack-5bfc169a99d8c71c752d12d73b9701834f2aad72.pack

Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/gitea-repositories-meta/user2/repo1.git/packed-refs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# pack-refs with: peeled fully-peeled sorted
0d653ed2b0d85ea39fefc1c193bf49c09eaac731 refs/heads/DefaultBranch
a270587a5cf3bcfa12c4c58f771ff58ee9694f43 refs/heads/branch2
0d653ed2b0d85ea39fefc1c193bf49c09eaac731 refs/heads/develop
0d653ed2b0d85ea39fefc1c193bf49c09eaac731 refs/heads/feature/1
448e82b9e44d980faeddf37c7a266eca00f8b8f5 refs/heads/home-md-img-check
0d653ed2b0d85ea39fefc1c193bf49c09eaac731 refs/heads/master
208f14c1297434afedbdd620102056999be5caf0 refs/heads/pr-to-update
46a25bce2a8312552689901abf21d32b0c3a794b refs/heads/sub-home-md-img-check
3fa2f829675543ecfc16b2891aebe8bf0608a8f4 refs/notes/commits
40587f82e2bae1309157cef04b91da7e96a7ed20 refs/pull/2/head
eee617916f575706143a8f5b76ce66d34840708a refs/pull/3/head
208f14c1297434afedbdd620102056999be5caf0 refs/pull/5/head
2f58a0d23e6e6bc235613f0d53482298a0862fac refs/tags/v0.1
0d653ed2b0d85ea39fefc1c193bf49c09eaac731 refs/tags/v1.1

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2f58a0d23e6e6bc235613f0d53482298a0862fac

This file was deleted.

4 changes: 2 additions & 2 deletions tests/integration/api_pull_commits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestAPIPullCommits(t *testing.T) {
return
}

assert.Equal(t, "5f22f7d0d95d614d25a5b68592adb345a4b5c7fd", commits[0].SHA)
assert.Equal(t, "4a357436d925b5c974181ff12a994538ddc5a269", commits[1].SHA)
assert.Equal(t, "eee617916f575706143a8f5b76ce66d34840708a", commits[0].SHA)
assert.Equal(t, "40587f82e2bae1309157cef04b91da7e96a7ed20", commits[1].SHA)
}

// TODO add tests for already merged PR and closed PR
Loading