Skip to content

Downloading translations and ignoring branch at Crowdin #2592

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

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
73041f3
Adding download translations and ignoring branch
jonasfranz Sep 23, 2017
6e178ea
Adding git-push
jonasfranz Sep 26, 2017
593fae2
Merge branch 'master' into patch-1
jonasfranz Sep 26, 2017
1db4eab
Update .drone.yml
jonasfranz Sep 26, 2017
9d36fac
Merge branch 'master' into patch-1
jonasfranz Oct 13, 2017
514006a
Fix orgnization user watch repository (#2670)
lunny Oct 14, 2017
e89bb7e
Allow custom SSH user in UI for built-in SSH server (#2617) (#2678)
pgaskin Oct 14, 2017
8863e74
Fix organization watch migration (#2703)
lafriks Oct 14, 2017
f42dbdb
Add Activity page to repository (#2674)
lafriks Oct 14, 2017
32ca299
Remove direct user adding to organization members (#2641)
lafriks Oct 15, 2017
1ec4dc6
Fix so that user can still fork his own repository to owned organizat…
lafriks Oct 15, 2017
4ccb0fe
fix .netrc authentication (#2700)
daviian Oct 15, 2017
c25303b
Fix activity locale (#2709)
ethantkoenig Oct 15, 2017
f3833b7
Create new branch from branch selection dropdown (#2130)
lafriks Oct 15, 2017
c7f4f07
Integration test for activity page (#2704)
lafriks Oct 15, 2017
a75d5c7
Fix plain readme didn't render correctly on repo home page (#2705)
lunny Oct 16, 2017
c1b0c9e
Fix PR, milestone and label functionality if issue unit is disabled (…
lafriks Oct 16, 2017
9e865ce
Merge password and 2fa page on user settings (#2695)
lunny Oct 16, 2017
33647aa
Fixing wrong translations on sorttype oldest/latest (#2720)
jonasfranz Oct 16, 2017
f4190f8
Render plain text README.txt monospaced (#2721)
jonasfranz Oct 16, 2017
af4a094
Fix semantic-ui style conflict with v-cloak (#2722)
lafriks Oct 17, 2017
dc4b941
Adding download translations and ignoring branch
jonasfranz Sep 23, 2017
6c95098
Adding git-push
jonasfranz Sep 26, 2017
baebafe
Update .drone.yml
jonasfranz Sep 26, 2017
fe8c55f
Merge remote-tracking branch 'jonas/patch-1' into patch-1
jonasfranz Oct 17, 2017
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
42 changes: 32 additions & 10 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ clone:
tags: true

pipeline:
download_translations:
image: jonasfranz/crowdin
pull: true
secrets: [ crowdin_key ]
project_identifier: gitea
ignore_branch: true
download: true
export_dir: options/locale/
when:
event: [ push ]
branch: [ master ]
git_push:
image: appleboy/drone-git-push
pull: true
secrets: [ git_push_ssh_key ]
force: false
commit: true
commit_message: "[skip ci] Updated translations via Crowdin"
when:
event: [ push ]
branch: [ master ]
pre-build:
image: webhippie/nodejs:latest
pull: true
Expand Down Expand Up @@ -212,27 +233,28 @@ pipeline:
event: [ push ]
branch: [ master ]

translations:
github:
image: plugins/github-release:1
pull: true
secrets: [ github_token ]
files:
- dist/release/*
when:
event: [ tag ]

upload_translations:
image: jonasfranz/crowdin
pull: true
secrets: [ crowdin_key ]
project_identifier: gitea
ignore_branch: true
download: false
files:
locale_en-US.ini: options/locale/locale_en-US.ini
when:
event: [ push ]
branch: [ master ]

github:
image: plugins/github-release:1
pull: true
secrets: [ github_token ]
files:
- dist/release/*
when:
event: [ tag ]

discord:
image: appleboy/drone-discord:1.0.0
pull: true
Expand Down
2 changes: 2 additions & 0 deletions conf/app.ini
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ LOCAL_ROOT_URL = %(PROTOCOL)s://%(HTTP_ADDR)s:%(HTTP_PORT)s/
DISABLE_SSH = false
; Whether use builtin SSH server or not.
START_SSH_SERVER = false
; Username to use for builtin SSH server. If blank, then it is the value of RUN_USER.
BUILTIN_SSH_SERVER_USER =
; Domain name to be exposed in clone URL
SSH_DOMAIN = %(DOMAIN)s
; Network interface builtin SSH server listens on
Expand Down
13 changes: 4 additions & 9 deletions integrations/editor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {

}

func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePath string) *TestResponse {

newContent := "Hello, World (Edited)\n"

func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePath, newContent string) *TestResponse {
// Get to the 'edit this file' page
req := NewRequest(t, "GET", path.Join(user, repo, "_edit", branch, filePath))
resp := session.MakeRequest(t, req, http.StatusOK)
Expand Down Expand Up @@ -121,9 +118,7 @@ func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePa
return resp
}

func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, branch, targetBranch, filePath string) *TestResponse {

newContent := "Hello, World (Edited)\n"
func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, branch, targetBranch, filePath, newContent string) *TestResponse {

// Get to the 'edit this file' page
req := NewRequest(t, "GET", path.Join(user, repo, "_edit", branch, filePath))
Expand Down Expand Up @@ -157,11 +152,11 @@ func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, bra
func TestEditFile(t *testing.T) {
prepareTestEnv(t)
session := loginUser(t, "user2")
testEditFile(t, session, "user2", "repo1", "master", "README.md")
testEditFile(t, session, "user2", "repo1", "master", "README.md", "Hello, World (Edited)\n")
}

func TestEditFileToNewBranch(t *testing.T) {
prepareTestEnv(t)
session := loginUser(t, "user2")
testEditFileToNewBranch(t, session, "user2", "repo1", "master", "feature/test", "README.md")
testEditFileToNewBranch(t, session, "user2", "repo1", "master", "feature/test", "README.md", "Hello, World (Edited)\n")
}
4 changes: 2 additions & 2 deletions integrations/links_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ func testLinksAsUser(userName string, t *testing.T) {
"/user2?tab=activity",
"/user/settings",
"/user/settings/avatar",
"/user/settings/password",
"/user/settings/security",
"/user/settings/security/two_factor/enroll",
"/user/settings/email",
"/user/settings/keys",
"/user/settings/applications",
"/user/settings/two_factor",
"/user/settings/account_link",
"/user/settings/organization",
"/user/settings/delete",
Expand Down
4 changes: 2 additions & 2 deletions integrations/pull_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch strin
func TestPullCreate(t *testing.T) {
prepareTestEnv(t)
session := loginUser(t, "user1")
testRepoFork(t, session)
testEditFile(t, session, "user1", "repo1", "master", "README.md")
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
testPullCreate(t, session, "user1", "repo1", "master")
}
8 changes: 4 additions & 4 deletions integrations/pull_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func testPullCleanUp(t *testing.T, session *TestSession, user, repo, pullnum str
func TestPullMerge(t *testing.T) {
prepareTestEnv(t)
session := loginUser(t, "user1")
testRepoFork(t, session)
testEditFile(t, session, "user1", "repo1", "master", "README.md")
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")

resp := testPullCreate(t, session, "user1", "repo1", "master")

Expand All @@ -61,8 +61,8 @@ func TestPullMerge(t *testing.T) {
func TestPullCleanUpAfterMerge(t *testing.T) {
prepareTestEnv(t)
session := loginUser(t, "user1")
testRepoFork(t, session)
testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feature/test", "README.md")
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feature/test", "README.md", "Hello, World (Edited)\n")

resp := testPullCreate(t, session, "user1", "repo1", "feature/test")

Expand Down
61 changes: 61 additions & 0 deletions integrations/repo_activity_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package integrations

import (
"net/http"
"strings"
"testing"

"github.com/stretchr/testify/assert"
)

func TestRepoActivity(t *testing.T) {
prepareTestEnv(t)
session := loginUser(t, "user1")

// Create PRs (1 merged & 2 proposed)
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
resp := testPullCreate(t, session, "user1", "repo1", "master")
elem := strings.Split(RedirectURL(t, resp), "/")
assert.EqualValues(t, "pulls", elem[3])
testPullMerge(t, session, elem[1], elem[2], elem[4])

testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feat/better_readme", "README.md", "Hello, World (Edited Again)\n")
testPullCreate(t, session, "user1", "repo1", "feat/better_readme")

testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feat/much_better_readme", "README.md", "Hello, World (Edited More)\n")
testPullCreate(t, session, "user1", "repo1", "feat/much_better_readme")

// Create issues (3 new issues)
testNewIssue(t, session, "user2", "repo1", "Issue 1")
testNewIssue(t, session, "user2", "repo1", "Issue 2")
testNewIssue(t, session, "user2", "repo1", "Issue 3")

// Create releases (1 new release)
createNewRelease(t, session, "/user2/repo1", "v1.0.0", "v1.0.0", false, false)

// Open Activity page and check stats
req := NewRequest(t, "GET", "/user2/repo1/activity")
resp = session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)

// Should be 1 published release
list := htmlDoc.doc.Find("#published-releases").Next().Find("p.desc")
assert.Len(t, list.Nodes, 1)

// Should be 1 merged pull request
list = htmlDoc.doc.Find("#merged-pull-requests").Next().Find("p.desc")
assert.Len(t, list.Nodes, 1)

// Should be 2 merged proposed pull requests
list = htmlDoc.doc.Find("#proposed-pull-requests").Next().Find("p.desc")
assert.Len(t, list.Nodes, 2)

// Should be 3 new issues
list = htmlDoc.doc.Find("#new-issues").Next().Find("p.desc")
assert.Len(t, list.Nodes, 3)
}
132 changes: 132 additions & 0 deletions integrations/repo_branch_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package integrations

import (
"net/http"
"path"
"strings"
"testing"

"github.com/Unknwon/i18n"
"github.com/stretchr/testify/assert"
)

func testCreateBranch(t *testing.T, session *TestSession, user, repo, oldRefName, newBranchName string, expectedStatus int) string {
var csrf string
if expectedStatus == http.StatusNotFound {
csrf = GetCSRF(t, session, path.Join(user, repo, "src/master"))
} else {
csrf = GetCSRF(t, session, path.Join(user, repo, "src", oldRefName))
}
req := NewRequestWithValues(t, "POST", path.Join(user, repo, "branches/_new", oldRefName), map[string]string{
"_csrf": csrf,
"new_branch_name": newBranchName,
})
resp := session.MakeRequest(t, req, expectedStatus)
if expectedStatus != http.StatusFound {
return ""
}
return RedirectURL(t, resp)
}

func TestCreateBranch(t *testing.T) {
tests := []struct {
OldBranchOrCommit string
NewBranch string
CreateRelease string
FlashMessage string
ExpectedStatus int
}{
{
OldBranchOrCommit: "master",
NewBranch: "feature/test1",
ExpectedStatus: http.StatusFound,
FlashMessage: i18n.Tr("en", "repo.branch.create_success", "feature/test1"),
},
{
OldBranchOrCommit: "master",
NewBranch: "",
ExpectedStatus: http.StatusFound,
FlashMessage: i18n.Tr("en", "form.NewBranchName") + i18n.Tr("en", "form.require_error"),
},
{
OldBranchOrCommit: "master",
NewBranch: "feature=test1",
ExpectedStatus: http.StatusFound,
FlashMessage: i18n.Tr("en", "form.NewBranchName") + i18n.Tr("en", "form.git_ref_name_error"),
},
{
OldBranchOrCommit: "master",
NewBranch: strings.Repeat("b", 101),
ExpectedStatus: http.StatusFound,
FlashMessage: i18n.Tr("en", "form.NewBranchName") + i18n.Tr("en", "form.max_size_error", "100"),
},
{
OldBranchOrCommit: "master",
NewBranch: "master",
ExpectedStatus: http.StatusFound,
FlashMessage: i18n.Tr("en", "repo.branch.branch_already_exists", "master"),
},
{
OldBranchOrCommit: "master",
NewBranch: "master/test",
ExpectedStatus: http.StatusFound,
FlashMessage: i18n.Tr("en", "repo.branch.branch_name_conflict", "master/test", "master"),
},
{
OldBranchOrCommit: "acd1d892867872cb47f3993468605b8aa59aa2e0",
NewBranch: "feature/test2",
ExpectedStatus: http.StatusNotFound,
},
{
OldBranchOrCommit: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
NewBranch: "feature/test3",
ExpectedStatus: http.StatusFound,
FlashMessage: i18n.Tr("en", "repo.branch.create_success", "feature/test3"),
},
{
OldBranchOrCommit: "master",
NewBranch: "v1.0.0",
CreateRelease: "v1.0.0",
ExpectedStatus: http.StatusFound,
FlashMessage: i18n.Tr("en", "repo.branch.tag_collision", "v1.0.0"),
},
{
OldBranchOrCommit: "v1.0.0",
NewBranch: "feature/test4",
CreateRelease: "v1.0.0",
ExpectedStatus: http.StatusFound,
FlashMessage: i18n.Tr("en", "repo.branch.create_success", "feature/test4"),
},
}
for _, test := range tests {
prepareTestEnv(t)
session := loginUser(t, "user2")
if test.CreateRelease != "" {
createNewRelease(t, session, "/user2/repo1", test.CreateRelease, test.CreateRelease, false, false)
}
redirectURL := testCreateBranch(t, session, "user2", "repo1", test.OldBranchOrCommit, test.NewBranch, test.ExpectedStatus)
if test.ExpectedStatus == http.StatusFound {
req := NewRequest(t, "GET", redirectURL)
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
assert.Equal(t,
test.FlashMessage,
strings.TrimSpace(htmlDoc.doc.Find(".ui.message").Text()),
)
}
}
}

func TestCreateBranchInvalidCSRF(t *testing.T) {
prepareTestEnv(t)
session := loginUser(t, "user2")
req := NewRequestWithValues(t, "POST", "user2/repo1/branches/_new/master", map[string]string{
"_csrf": "fake_csrf",
"new_branch_name": "test",
})
session.MakeRequest(t, req, http.StatusBadRequest)
}
Loading