Skip to content

Commit

Permalink
Merge branch 'master' into watchonchanges
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillermo Prandi committed Jul 30, 2019
2 parents ce99d45 + a957d4e commit 7781419
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 6 deletions.
1 change: 1 addition & 0 deletions integrations/html_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type HTMLDoc struct {

// NewHTMLParser parse html file
func NewHTMLParser(t testing.TB, body *bytes.Buffer) *HTMLDoc {
t.Helper()
doc, err := goquery.NewDocumentFromReader(body)
assert.NoError(t, err)
return &HTMLDoc{doc: doc}
Expand Down
17 changes: 17 additions & 0 deletions integrations/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func initIntegrationTest() {
}

func prepareTestEnv(t testing.TB, skip ...int) {
t.Helper()
ourSkip := 2
if len(skip) > 0 {
ourSkip += skip[0]
Expand Down Expand Up @@ -201,6 +202,7 @@ func (s *TestSession) GetCookie(name string) *http.Cookie {
}

func (s *TestSession) MakeRequest(t testing.TB, req *http.Request, expectedStatus int) *httptest.ResponseRecorder {
t.Helper()
baseURL, err := url.Parse(setting.AppURL)
assert.NoError(t, err)
for _, c := range s.jar.Cookies(baseURL) {
Expand All @@ -217,6 +219,7 @@ func (s *TestSession) MakeRequest(t testing.TB, req *http.Request, expectedStatu
}

func (s *TestSession) MakeRequestNilResponseRecorder(t testing.TB, req *http.Request, expectedStatus int) *NilResponseRecorder {
t.Helper()
baseURL, err := url.Parse(setting.AppURL)
assert.NoError(t, err)
for _, c := range s.jar.Cookies(baseURL) {
Expand All @@ -237,13 +240,15 @@ const userPassword = "password"
var loginSessionCache = make(map[string]*TestSession, 10)

func emptyTestSession(t testing.TB) *TestSession {
t.Helper()
jar, err := cookiejar.New(nil)
assert.NoError(t, err)

return &TestSession{jar: jar}
}

func loginUser(t testing.TB, userName string) *TestSession {
t.Helper()
if session, ok := loginSessionCache[userName]; ok {
return session
}
Expand All @@ -253,6 +258,7 @@ func loginUser(t testing.TB, userName string) *TestSession {
}

func loginUserWithPassword(t testing.TB, userName, password string) *TestSession {
t.Helper()
req := NewRequest(t, "GET", "/user/login")
resp := MakeRequest(t, req, http.StatusOK)

Expand All @@ -278,6 +284,7 @@ func loginUserWithPassword(t testing.TB, userName, password string) *TestSession
}

func getTokenForLoggedInUser(t testing.TB, session *TestSession) string {
t.Helper()
req := NewRequest(t, "GET", "/user/settings/applications")
resp := session.MakeRequest(t, req, http.StatusOK)
doc := NewHTMLParser(t, resp.Body)
Expand All @@ -294,14 +301,17 @@ func getTokenForLoggedInUser(t testing.TB, session *TestSession) string {
}

func NewRequest(t testing.TB, method, urlStr string) *http.Request {
t.Helper()
return NewRequestWithBody(t, method, urlStr, nil)
}

func NewRequestf(t testing.TB, method, urlFormat string, args ...interface{}) *http.Request {
t.Helper()
return NewRequest(t, method, fmt.Sprintf(urlFormat, args...))
}

func NewRequestWithValues(t testing.TB, method, urlStr string, values map[string]string) *http.Request {
t.Helper()
urlValues := url.Values{}
for key, value := range values {
urlValues[key] = []string{value}
Expand All @@ -312,6 +322,7 @@ func NewRequestWithValues(t testing.TB, method, urlStr string, values map[string
}

func NewRequestWithJSON(t testing.TB, method, urlStr string, v interface{}) *http.Request {
t.Helper()
jsonBytes, err := json.Marshal(v)
assert.NoError(t, err)
req := NewRequestWithBody(t, method, urlStr, bytes.NewBuffer(jsonBytes))
Expand All @@ -320,6 +331,7 @@ func NewRequestWithJSON(t testing.TB, method, urlStr string, v interface{}) *htt
}

func NewRequestWithBody(t testing.TB, method, urlStr string, body io.Reader) *http.Request {
t.Helper()
request, err := http.NewRequest(method, urlStr, body)
assert.NoError(t, err)
request.RequestURI = urlStr
Expand All @@ -334,6 +346,7 @@ func AddBasicAuthHeader(request *http.Request, username string) *http.Request {
const NoExpectedStatus = -1

func MakeRequest(t testing.TB, req *http.Request, expectedStatus int) *httptest.ResponseRecorder {
t.Helper()
recorder := httptest.NewRecorder()
mac.ServeHTTP(recorder, req)
if expectedStatus != NoExpectedStatus {
Expand All @@ -346,6 +359,7 @@ func MakeRequest(t testing.TB, req *http.Request, expectedStatus int) *httptest.
}

func MakeRequestNilResponseRecorder(t testing.TB, req *http.Request, expectedStatus int) *NilResponseRecorder {
t.Helper()
recorder := NewNilResponseRecorder()
mac.ServeHTTP(recorder, req)
if expectedStatus != NoExpectedStatus {
Expand All @@ -359,6 +373,7 @@ func MakeRequestNilResponseRecorder(t testing.TB, req *http.Request, expectedSta

// logUnexpectedResponse logs the contents of an unexpected response.
func logUnexpectedResponse(t testing.TB, recorder *httptest.ResponseRecorder) {
t.Helper()
respBytes := recorder.Body.Bytes()
if len(respBytes) == 0 {
return
Expand All @@ -381,11 +396,13 @@ func logUnexpectedResponse(t testing.TB, recorder *httptest.ResponseRecorder) {
}

func DecodeJSON(t testing.TB, resp *httptest.ResponseRecorder, v interface{}) {
t.Helper()
decoder := json.NewDecoder(resp.Body)
assert.NoError(t, decoder.Decode(v))
}

func GetCSRF(t testing.TB, session *TestSession, urlStr string) string {
t.Helper()
req := NewRequest(t, "GET", urlStr)
resp := session.MakeRequest(t, req, http.StatusOK)
doc := NewHTMLParser(t, resp.Body)
Expand Down
2 changes: 2 additions & 0 deletions models/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ var migrations = []Migration{
NewMigration("add commit status context field to commit_status", addCommitStatusContext),
// v89 -> v90
NewMigration("add original author/url migration info to issues, comments, and repo ", addOriginalMigrationInfo),
// v90 -> v91
NewMigration("change length of some repository columns", changeSomeColumnsLengthOfRepo),
}

// Migrate database to current version
Expand Down
18 changes: 18 additions & 0 deletions models/migrations/v90.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2019 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 migrations

import "github.com/go-xorm/xorm"

func changeSomeColumnsLengthOfRepo(x *xorm.Engine) error {
type Repository struct {
ID int64 `xorm:"pk autoincr"`
Description string `xorm:"TEXT"`
Website string `xorm:"VARCHAR(2048)"`
OriginalURL string `xorm:"VARCHAR(2048)"`
}

return x.Sync2(new(Repository))
}
6 changes: 3 additions & 3 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ type Repository struct {
Owner *User `xorm:"-"`
LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"`
Name string `xorm:"INDEX NOT NULL"`
Description string
Website string
OriginalURL string
Description string `xorm:"TEXT"`
Website string `xorm:"VARCHAR(2048)"`
OriginalURL string `xorm:"VARCHAR(2048)"`
DefaultBranch string

NumWatches int
Expand Down
2 changes: 1 addition & 1 deletion modules/migrations/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) err
RepoID: g.repo.ID,
Name: milestone.Title,
Content: milestone.Description,
IsClosed: milestone.State == "close",
IsClosed: milestone.State == "closed",
DeadlineUnix: deadline,
}
if ms.IsClosed && milestone.Closed != nil {
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_es-ES.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,7 @@ branch.restore_success=La rama '%s' ha sido restaurada.
branch.restore_failed=Fallo al restaurar la rama %s.
branch.protected_deletion_failed=La rama '%s' está protegida. No se puede eliminar.
branch.restore=Restaurar rama '%s'
branch.download=Descargar rama '%s'

topic.manage_topics=Administrar temas
topic.done=Hecho
Expand Down
3 changes: 3 additions & 0 deletions options/locale/locale_fr-FR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ editor.delete=Supprimer '%s'
editor.commit_message_desc=Ajouter une description détaillée facultative…
editor.commit_directly_to_this_branch=Soumettre directement dans la branche <strong class="branch-name">%s</strong>.
editor.create_new_branch=Créer une <strong>nouvelle branche</strong> pour cette révision et envoyer une nouvelle demande d'ajout.
editor.propose_file_change=Proposer une modification du fichier
editor.new_branch_name_desc=Nouveau nom de la branche…
editor.cancel=Annuler
editor.filename_cannot_be_empty=Le nom de fichier ne peut être vide.
Expand Down Expand Up @@ -1405,6 +1406,8 @@ branch.deleted_by=Supprimée par %s
branch.restore_success=La branche "%s" a été restaurée.
branch.restore_failed=La restauration de la branche '%s' a échoué.
branch.protected_deletion_failed=La branche '%s' est protégé. Il ne peut pas être supprimé.
branch.restore=Restaurer la branche '%s'
branch.download=Télécharger la branche '%s'
topic.manage_topics=Gérer les sujets
topic.done=Terminé
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_ja-JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,7 @@ branch.restore_success=ブランチ '%s' を復元しました。
branch.restore_failed=ブランチ '%s' の復元に失敗しました。
branch.protected_deletion_failed=ブランチ '%s' は保護されています。 削除できません。
branch.restore=ブランチ '%s' の復元
branch.download=ブランチ '%s' をダウンロード

topic.manage_topics=トピックの管理
topic.done=完了
Expand Down
2 changes: 2 additions & 0 deletions options/locale/locale_pt-BR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,8 @@ branch.deleted_by=Excluído por %s
branch.restore_success=A branch '%s' foi restaurada.
branch.restore_failed=Falha ao restaurar a branch %s.
branch.protected_deletion_failed=A branch '%s' está protegida. Ela não pode ser excluída.
branch.restore=Restaurar branch '%s'
branch.download=Baixar branch '%s'

topic.manage_topics=Gerenciar Tópicos
topic.done=Feito
Expand Down
2 changes: 1 addition & 1 deletion public/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ footer .ui.left,footer .ui.right{line-height:40px}
.repository .segment.reactions .select-reaction{float:none}
.repository .segment.reactions .select-reaction:not(.active) a{display:none}
.repository .segment.reactions:hover .select-reaction a{display:block}
.user-cards .list{padding:0}
.user-cards .list{padding:0;display:flex;flex-wrap:wrap}
.user-cards .list .item{list-style:none;width:32%;margin:10px 10px 10px 0;padding-bottom:14px;float:left}
.user-cards .list .item .avatar{width:48px;height:48px;float:left;display:block;margin-right:10px}
.user-cards .list .item .name{margin-top:0;margin-bottom:0;font-weight:400}
Expand Down
2 changes: 2 additions & 0 deletions public/less/_repository.less
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,8 @@
&.user-cards {
.list {
padding: 0;
display: flex;
flex-wrap: wrap;

.item {
list-style: none;
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/branch/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
</div>
</div>
{{end}}
{{if and $.IsWriter (not $.IsMirror) (not .IsProtected)}}
{{if and $.IsWriter (not $.IsMirror) (not $.Repository.IsArchived) (not .IsProtected)}}
{{if .IsDeleted}}
<a class="ui basic jump button icon poping up undo-button" href data-url="{{$.Link}}/restore?branch_id={{.DeletedBranch.ID | urlquery}}&name={{.DeletedBranch.Name | urlquery}}" data-content="{{$.i18n.Tr "repo.branch.restore" (.Name | EscapePound)}}" data-variation="tiny inverted" data-position="top right"><i class="octicon octicon-reply text blue"></i></a>
{{else}}
Expand Down

0 comments on commit 7781419

Please sign in to comment.