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

Update to Xorm v0.7.9 #8355

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9dbabcd
Merge go-gitea/master into master
guillep2k Sep 14, 2019
889c619
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 14, 2019
d7c46c8
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 15, 2019
8eaacbf
Merge remote-tracking branch 'refs/remotes/origin/master'
guillep2k Sep 19, 2019
de5aa64
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 19, 2019
80c6f2b
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 20, 2019
ac40f7f
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 22, 2019
f6ac46b
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 23, 2019
b563158
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 25, 2019
6f55d1e
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 25, 2019
188e164
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 26, 2019
fd6fe8c
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 27, 2019
54624dd
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 29, 2019
e2a6388
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Sep 30, 2019
b8d4abf
Merge branch 'master' of github.com:go-gitea/gitea
guillep2k Oct 2, 2019
5cf823a
Merge pull request #9 from go-gitea/master
guillep2k Oct 2, 2019
a9869bf
[arc-green] white on hover for active menu items (#8344)
spaeps Oct 2, 2019
68b1381
Api: advanced settings for repository (external wiki, issue tracker e…
davidsvantesson Oct 2, 2019
808a477
Change general form binding to gogs form (#8334)
aamsur Oct 2, 2019
15214fc
[skip ci] Updated translations via Crowdin
GiteaBot Oct 2, 2019
ca0db2e
Upgrade to xorm v0.7.9
guillep2k Oct 2, 2019
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ require (
github.com/go-redis/redis v6.15.2+incompatible
github.com/go-sql-driver/mysql v1.4.1
github.com/go-swagger/go-swagger v0.20.1
github.com/go-xorm/xorm v0.7.8
github.com/go-xorm/xorm v0.7.9
github.com/gobwas/glob v0.2.3
github.com/gogits/chardet v0.0.0-20150115103509-2404f7772561
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
github.com/go-xorm/xorm v0.7.8 h1:rKxZJB9mWQ9Nw2TbjsepiThR031jkGePOWXwTtEAU08=
github.com/go-xorm/xorm v0.7.8/go.mod h1:XiVxrMMIhFkwSkh96BW7PACl7UhLtx2iJIHMdmjh5sQ=
github.com/go-xorm/xorm v0.7.9 h1:LZze6n1UvRmM5gpL9/U9Gucwqo6aWlFVlfcHKH10qA0=
github.com/go-xorm/xorm v0.7.9/go.mod h1:XiVxrMMIhFkwSkh96BW7PACl7UhLtx2iJIHMdmjh5sQ=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
Expand Down
106 changes: 105 additions & 1 deletion integrations/api_repo_edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,35 @@ func getRepoEditOptionFromRepo(repo *models.Repository) *api.EditRepoOption {
website := repo.Website
private := repo.IsPrivate
hasIssues := false
if _, err := repo.GetUnit(models.UnitTypeIssues); err == nil {
var internalTracker *api.InternalTracker
var externalTracker *api.ExternalTracker
if unit, err := repo.GetUnit(models.UnitTypeIssues); err == nil {
config := unit.IssuesConfig()
hasIssues = true
internalTracker = &api.InternalTracker{
EnableTimeTracker: config.EnableTimetracker,
AllowOnlyContributorsToTrackTime: config.AllowOnlyContributorsToTrackTime,
EnableIssueDependencies: config.EnableDependencies,
}
} else if unit, err := repo.GetUnit(models.UnitTypeExternalTracker); err == nil {
config := unit.ExternalTrackerConfig()
hasIssues = true
externalTracker = &api.ExternalTracker{
ExternalTrackerURL: config.ExternalTrackerURL,
ExternalTrackerFormat: config.ExternalTrackerFormat,
ExternalTrackerStyle: config.ExternalTrackerStyle,
}
}
hasWiki := false
var externalWiki *api.ExternalWiki
if _, err := repo.GetUnit(models.UnitTypeWiki); err == nil {
hasWiki = true
} else if unit, err := repo.GetUnit(models.UnitTypeExternalWiki); err == nil {
hasWiki = true
config := unit.ExternalWikiConfig()
externalWiki = &api.ExternalWiki{
ExternalWikiURL: config.ExternalWikiURL,
}
}
defaultBranch := repo.DefaultBranch
hasPullRequests := false
Expand All @@ -53,7 +76,10 @@ func getRepoEditOptionFromRepo(repo *models.Repository) *api.EditRepoOption {
Website: &website,
Private: &private,
HasIssues: &hasIssues,
ExternalTracker: externalTracker,
InternalTracker: internalTracker,
HasWiki: &hasWiki,
ExternalWiki: externalWiki,
DefaultBranch: &defaultBranch,
HasPullRequests: &hasPullRequests,
IgnoreWhitespaceConflicts: &ignoreWhitespaceConflicts,
Expand Down Expand Up @@ -143,6 +169,84 @@ func TestAPIRepoEdit(t *testing.T) {
assert.Equal(t, *repoEditOption.Archived, *repo1editedOption.Archived)
assert.Equal(t, *repoEditOption.Private, *repo1editedOption.Private)
assert.Equal(t, *repoEditOption.HasWiki, *repo1editedOption.HasWiki)

//Test editing repo1 to use internal issue and wiki (default)
*repoEditOption.HasIssues = true
repoEditOption.ExternalTracker = nil
repoEditOption.InternalTracker = &api.InternalTracker{
EnableTimeTracker: false,
AllowOnlyContributorsToTrackTime: false,
EnableIssueDependencies: false,
}
*repoEditOption.HasWiki = true
repoEditOption.ExternalWiki = nil
url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, *repoEditOption.Name, token2)
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
resp = session.MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &repo)
assert.NotNil(t, repo)
// check repo1 was written to database
repo1edited = models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
repo1editedOption = getRepoEditOptionFromRepo(repo1edited)
assert.Equal(t, *repo1editedOption.HasIssues, true)
assert.Nil(t, repo1editedOption.ExternalTracker)
assert.Equal(t, *repo1editedOption.InternalTracker, *repoEditOption.InternalTracker)
assert.Equal(t, *repo1editedOption.HasWiki, true)
assert.Nil(t, repo1editedOption.ExternalWiki)

//Test editing repo1 to use external issue and wiki
repoEditOption.ExternalTracker = &api.ExternalTracker{
ExternalTrackerURL: "http://www.somewebsite.com",
ExternalTrackerFormat: "http://www.somewebsite.com/{user}/{repo}?issue={index}",
ExternalTrackerStyle: "alphanumeric",
}
repoEditOption.ExternalWiki = &api.ExternalWiki{
ExternalWikiURL: "http://www.somewebsite.com",
}
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
resp = session.MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &repo)
assert.NotNil(t, repo)
// check repo1 was written to database
repo1edited = models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
repo1editedOption = getRepoEditOptionFromRepo(repo1edited)
assert.Equal(t, *repo1editedOption.HasIssues, true)
assert.Equal(t, *repo1editedOption.ExternalTracker, *repoEditOption.ExternalTracker)
assert.Equal(t, *repo1editedOption.HasWiki, true)
assert.Equal(t, *repo1editedOption.ExternalWiki, *repoEditOption.ExternalWiki)

// Do some tests with invalid URL for external tracker and wiki
repoEditOption.ExternalTracker.ExternalTrackerURL = "htp://www.somewebsite.com"
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
repoEditOption.ExternalTracker.ExternalTrackerURL = "http://www.somewebsite.com"
repoEditOption.ExternalTracker.ExternalTrackerFormat = "http://www.somewebsite.com/{user/{repo}?issue={index}"
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
repoEditOption.ExternalTracker.ExternalTrackerFormat = "http://www.somewebsite.com/{user}/{repo}?issue={index}"
repoEditOption.ExternalWiki.ExternalWikiURL = "htp://www.somewebsite.com"
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)

//Test small repo change through API with issue and wiki option not set; They shall not be touched.
*repoEditOption.Description = "small change"
repoEditOption.HasIssues = nil
repoEditOption.ExternalTracker = nil
repoEditOption.HasWiki = nil
repoEditOption.ExternalWiki = nil
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
resp = session.MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &repo)
assert.NotNil(t, repo)
// check repo1 was written to database
repo1edited = models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
repo1editedOption = getRepoEditOptionFromRepo(repo1edited)
assert.Equal(t, *repo1editedOption.Description, *repoEditOption.Description)
assert.Equal(t, *repo1editedOption.HasIssues, true)
assert.NotNil(t, *repo1editedOption.ExternalTracker)
assert.Equal(t, *repo1editedOption.HasWiki, true)
assert.NotNil(t, *repo1editedOption.ExternalWiki)

// reset repo in db
url = fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", user2.Name, *repoEditOption.Name, token2)
req = NewRequestWithJSON(t, "PATCH", url, &origRepoEditOption)
Expand Down
28 changes: 27 additions & 1 deletion models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,35 @@ func (repo *Repository) innerAPIFormat(e Engine, mode AccessMode, isParent bool)
}
}
hasIssues := false
if _, err := repo.getUnit(e, UnitTypeIssues); err == nil {
var externalTracker *api.ExternalTracker
var internalTracker *api.InternalTracker
if unit, err := repo.getUnit(e, UnitTypeIssues); err == nil {
config := unit.IssuesConfig()
hasIssues = true
internalTracker = &api.InternalTracker{
EnableTimeTracker: config.EnableTimetracker,
AllowOnlyContributorsToTrackTime: config.AllowOnlyContributorsToTrackTime,
EnableIssueDependencies: config.EnableDependencies,
}
} else if unit, err := repo.getUnit(e, UnitTypeExternalTracker); err == nil {
config := unit.ExternalTrackerConfig()
hasIssues = true
externalTracker = &api.ExternalTracker{
ExternalTrackerURL: config.ExternalTrackerURL,
ExternalTrackerFormat: config.ExternalTrackerFormat,
ExternalTrackerStyle: config.ExternalTrackerStyle,
}
}
hasWiki := false
var externalWiki *api.ExternalWiki
if _, err := repo.getUnit(e, UnitTypeWiki); err == nil {
hasWiki = true
} else if unit, err := repo.getUnit(e, UnitTypeExternalWiki); err == nil {
hasWiki = true
config := unit.ExternalWikiConfig()
externalWiki = &api.ExternalWiki{
ExternalWikiURL: config.ExternalWikiURL,
}
}
hasPullRequests := false
ignoreWhitespaceConflicts := false
Expand Down Expand Up @@ -324,7 +347,10 @@ func (repo *Repository) innerAPIFormat(e Engine, mode AccessMode, isParent bool)
Updated: repo.UpdatedUnix.AsTime(),
Permissions: permission,
HasIssues: hasIssues,
ExternalTracker: externalTracker,
InternalTracker: internalTracker,
HasWiki: hasWiki,
ExternalWiki: externalWiki,
HasPullRequests: hasPullRequests,
IgnoreWhitespaceConflicts: ignoreWhitespaceConflicts,
AllowMerge: allowMerge,
Expand Down
60 changes: 49 additions & 11 deletions modules/structs/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,35 @@ type Permission struct {
Pull bool `json:"pull"`
}

// InternalTracker represents settings for internal tracker
// swagger:model
type InternalTracker struct {
// Enable time tracking (Built-in issue tracker)
EnableTimeTracker bool `json:"enable_time_tracker"`
// Let only contributors track time (Built-in issue tracker)
AllowOnlyContributorsToTrackTime bool `json:"allow_only_contributors_to_track_time"`
// Enable dependencies for issues and pull requests (Built-in issue tracker)
EnableIssueDependencies bool `json:"enable_issue_dependencies"`
}

// ExternalTracker represents settings for external tracker
// swagger:model
type ExternalTracker struct {
// URL of external issue tracker.
ExternalTrackerURL string `json:"external_tracker_url"`
// External Issue Tracker URL Format. Use the placeholders {user}, {repo} and {index} for the username, repository name and issue index.
ExternalTrackerFormat string `json:"external_tracker_format"`
// External Issue Tracker Number Format, either `numeric` or `alphanumeric`
ExternalTrackerStyle string `json:"external_tracker_style"`
}

// ExternalWiki represents setting for external wiki
// swagger:model
type ExternalWiki struct {
// URL of external wiki.
ExternalWikiURL string `json:"external_wiki_url"`
}

// Repository represents a repository
type Repository struct {
ID int64 `json:"id"`
Expand Down Expand Up @@ -42,17 +71,20 @@ type Repository struct {
// swagger:strfmt date-time
Created time.Time `json:"created_at"`
// swagger:strfmt date-time
Updated time.Time `json:"updated_at"`
Permissions *Permission `json:"permissions,omitempty"`
HasIssues bool `json:"has_issues"`
HasWiki bool `json:"has_wiki"`
HasPullRequests bool `json:"has_pull_requests"`
IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"`
AllowMerge bool `json:"allow_merge_commits"`
AllowRebase bool `json:"allow_rebase"`
AllowRebaseMerge bool `json:"allow_rebase_explicit"`
AllowSquash bool `json:"allow_squash_merge"`
AvatarURL string `json:"avatar_url"`
Updated time.Time `json:"updated_at"`
Permissions *Permission `json:"permissions,omitempty"`
HasIssues bool `json:"has_issues"`
InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
HasWiki bool `json:"has_wiki"`
ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"`
HasPullRequests bool `json:"has_pull_requests"`
IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"`
AllowMerge bool `json:"allow_merge_commits"`
AllowRebase bool `json:"allow_rebase"`
AllowRebaseMerge bool `json:"allow_rebase_explicit"`
AllowSquash bool `json:"allow_squash_merge"`
AvatarURL string `json:"avatar_url"`
}

// CreateRepoOption options when creating repository
Expand Down Expand Up @@ -95,8 +127,14 @@ type EditRepoOption struct {
Private *bool `json:"private,omitempty"`
// either `true` to enable issues for this repository or `false` to disable them.
HasIssues *bool `json:"has_issues,omitempty"`
// set this structure to configure internal issue tracker (requires has_issues)
InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
// set this structure to use external issue tracker (requires has_issues)
ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
// either `true` to enable the wiki for this repository or `false` to disable it.
HasWiki *bool `json:"has_wiki,omitempty"`
// set this structure to use external wiki instead of internal (requires has_wiki)
ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"`
// sets the default branch for this repository.
DefaultBranch *string `json:"default_branch,omitempty"`
// either `true` to allow pull requests, or `false` to prevent pull request.
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 @@ -1325,6 +1325,7 @@ settings.protect_merge_whitelist_committers_desc=ホワイトリストに登録
settings.protect_merge_whitelist_users=マージ・ホワイトリストに含むユーザー:
settings.protect_merge_whitelist_teams=マージ・ホワイトリストに含むチーム:
settings.protect_check_status_contexts=ステータスチェックを有効にする
settings.protect_check_status_contexts_desc=マージの前にステータスチェックがパスしていることを必須にします。 このルールの対象ブランチへのマージが可能となるまでに、事前にパスしている必要があるステータスチェックを選んでください。 有効にする場合は、まずコミットを別のブランチにプッシュし、ステータスチェックがパスしたあと、このルールの対象ブランチにマージするか、直接プッシュするようにします。 条件が選択されていない場合は、最後のコミットが成功していることが必須条件となります。
settings.protect_check_status_contexts_list=1週間の間にこのリポジトリにあったステータスチェック
settings.protect_required_approvals=必要な承認数:
settings.protect_required_approvals_desc=ホワイトリストに登録したユーザーやチームがレビューを行い、肯定的なレビューの数を満たしたプルリクエストしかマージできないようにします。
Expand Down
2 changes: 1 addition & 1 deletion public/css/theme-arc-green.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ a:hover{color:#a0cc75}
.ui.attached.table{border:1px solid #304251;background:#304251}
.feeds .list ul li:not(:last-child){border-bottom:1px solid #333640}
.feeds .list ul li.private{background:#353945;border:1px solid #333640}
.ui.secondary.menu .dropdown.item:hover,.ui.secondary.menu .link.item:hover,.ui.secondary.menu a.item:hover{color:#fff}
.ui.secondary.menu .active.item:hover,.ui.secondary.menu .dropdown.item:hover,.ui.secondary.menu .link.item:hover,.ui.secondary.menu a.item:hover{color:#fff}
.ui.menu .ui.dropdown .menu>.item{background:#2c303a!important;color:#9e9e9e!important}
.ui.secondary.menu .dropdown.item>.menu,.ui.text.menu .dropdown.item>.menu{border:1px solid #434444}
footer{background:#2e323e;border-top:1px solid #313131}
Expand Down
1 change: 1 addition & 0 deletions public/less/themes/arc-green.less
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ a:hover {

.ui.secondary.menu .dropdown.item:hover,
.ui.secondary.menu .link.item:hover,
.ui.secondary.menu .active.item:hover,
.ui.secondary.menu a.item:hover {
color: #ffffff;
}
Expand Down
Loading