Skip to content

Commit 68d57a1

Browse files
committed
Merge remote-tracking branch 'origin' into force_user_password_change_fix
2 parents 0bef325 + 5fa403c commit 68d57a1

File tree

104 files changed

+3178
-1469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+3178
-1469
lines changed

BSDmakefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# GNU makefile proxy script for BSD make
2+
# Written and maintained by Mahmoud Al-Qudsi <[email protected]>
3+
# Copyright NeoSmart Technologies <https://neosmart.net/> 2014-2018
4+
# Obtain updates from <https://github.com/neosmart/gmake-proxy>
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions are met:
8+
#
9+
# 1. Redistributions of source code must retain the above copyright notice, this
10+
# list of conditions and the following disclaimer.
11+
#
12+
# 2. Redistributions in binary form must reproduce the above copyright notice,
13+
# this list of conditions and the following disclaimer in the documentation
14+
# and/or other materials provided with the distribution.
15+
#
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
JARG =
28+
GMAKE = "gmake"
29+
#When gmake is called from another make instance, -w is automatically added
30+
#which causes extraneous messages about directory changes to be emitted.
31+
#--no-print-directory silences these messages.
32+
GARGS = "--no-print-directory"
33+
34+
.if "$(.MAKE.JOBS)" != ""
35+
JARG = -j$(.MAKE.JOBS)
36+
.endif
37+
38+
#by default bmake will cd into ./obj first
39+
.OBJDIR: ./
40+
41+
.PHONY: FRC
42+
$(.TARGETS): FRC
43+
$(GMAKE) $(GARGS) $(.TARGETS:S,.DONE,,) $(JARG)
44+
45+
.DONE .DEFAULT: .SILENT
46+
$(GMAKE) $(GARGS) $(.TARGETS:S,.DONE,,) $(JARG)
47+
48+
.ERROR: .SILENT
49+
if ! which $(GMAKE) > /dev/null; then \
50+
echo "GNU Make is required!"; \
51+
fi

Gopkg.lock

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ignored = ["google.golang.org/appengine*"]
3333
[[override]]
3434
name = "github.com/go-xorm/xorm"
3535
#version = "0.6.5"
36-
revision = "d4149d1eee0c2c488a74a5863fd9caf13d60fd03"
36+
revision = "ad69f7d8f0861a29438154bb0a20b60501298480"
3737

3838
[[override]]
3939
name = "github.com/go-sql-driver/mysql"

custom/conf/app.ini.sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ DEFAULT_KEEP_EMAIL_PRIVATE = false
316316
; Default value for AllowCreateOrganization
317317
; Every new user will have rights set to create organizations depending on this setting
318318
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
319+
; Default value for EnableDependencies
320+
; Repositories will use depencies by default depending on this setting
321+
DEFAULT_ENABLE_DEPENDENCIES = true
319322
; Enable Timetracking
320323
ENABLE_TIMETRACKING = true
321324
; Default value for EnableTimetracking

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
182182
- `CAPTCHA_TYPE`: **image**: \[image, recaptcha\]
183183
- `RECAPTCHA_SECRET`: **""**: Go to https://www.google.com/recaptcha/admin to get a secret for recaptcha
184184
- `RECAPTCHA_SITEKEY`: **""**: Go to https://www.google.com/recaptcha/admin to get a sitekey for recaptcha
185+
- `DEFAULT_ENABLE_DEPENDENCIES`: **true** Enable this to have dependencies enabled by default.
185186

186187
## Webhook (`webhook`)
187188

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"code.gitea.io/gitea/modules/log"
1515
"code.gitea.io/gitea/modules/setting"
1616
// register supported doc types
17+
_ "code.gitea.io/gitea/modules/markup/csv"
1718
_ "code.gitea.io/gitea/modules/markup/markdown"
1819
_ "code.gitea.io/gitea/modules/markup/orgmode"
1920

models/action.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit) err
477477
}
478478

479479
if err = issue.ChangeStatus(doer, repo, true); err != nil {
480+
// Don't return an error when dependencies are open as this would let the push fail
481+
if IsErrDependenciesLeft(err) {
482+
return nil
483+
}
480484
return err
481485
}
482486
}

models/error.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,3 +1259,88 @@ func IsErrU2FRegistrationNotExist(err error) bool {
12591259
_, ok := err.(ErrU2FRegistrationNotExist)
12601260
return ok
12611261
}
1262+
1263+
// .___ ________ .___ .__
1264+
// | | ______ ________ __ ____ \______ \ ____ ______ ____ ____ __| _/____ ____ ____ |__| ____ ______
1265+
// | |/ ___// ___/ | \_/ __ \ | | \_/ __ \\____ \_/ __ \ / \ / __ |/ __ \ / \_/ ___\| |/ __ \ / ___/
1266+
// | |\___ \ \___ \| | /\ ___/ | ` \ ___/| |_> > ___/| | \/ /_/ \ ___/| | \ \___| \ ___/ \___ \
1267+
// |___/____ >____ >____/ \___ >_______ /\___ > __/ \___ >___| /\____ |\___ >___| /\___ >__|\___ >____ >
1268+
// \/ \/ \/ \/ \/|__| \/ \/ \/ \/ \/ \/ \/ \/
1269+
1270+
// ErrDependencyExists represents a "DependencyAlreadyExists" kind of error.
1271+
type ErrDependencyExists struct {
1272+
IssueID int64
1273+
DependencyID int64
1274+
}
1275+
1276+
// IsErrDependencyExists checks if an error is a ErrDependencyExists.
1277+
func IsErrDependencyExists(err error) bool {
1278+
_, ok := err.(ErrDependencyExists)
1279+
return ok
1280+
}
1281+
1282+
func (err ErrDependencyExists) Error() string {
1283+
return fmt.Sprintf("issue dependency does already exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
1284+
}
1285+
1286+
// ErrDependencyNotExists represents a "DependencyAlreadyExists" kind of error.
1287+
type ErrDependencyNotExists struct {
1288+
IssueID int64
1289+
DependencyID int64
1290+
}
1291+
1292+
// IsErrDependencyNotExists checks if an error is a ErrDependencyExists.
1293+
func IsErrDependencyNotExists(err error) bool {
1294+
_, ok := err.(ErrDependencyNotExists)
1295+
return ok
1296+
}
1297+
1298+
func (err ErrDependencyNotExists) Error() string {
1299+
return fmt.Sprintf("issue dependency does not exist [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
1300+
}
1301+
1302+
// ErrCircularDependency represents a "DependencyCircular" kind of error.
1303+
type ErrCircularDependency struct {
1304+
IssueID int64
1305+
DependencyID int64
1306+
}
1307+
1308+
// IsErrCircularDependency checks if an error is a ErrCircularDependency.
1309+
func IsErrCircularDependency(err error) bool {
1310+
_, ok := err.(ErrCircularDependency)
1311+
return ok
1312+
}
1313+
1314+
func (err ErrCircularDependency) Error() string {
1315+
return fmt.Sprintf("circular dependencies exists (two issues blocking each other) [issue id: %d, dependency id: %d]", err.IssueID, err.DependencyID)
1316+
}
1317+
1318+
// ErrDependenciesLeft represents an error where the issue you're trying to close still has dependencies left.
1319+
type ErrDependenciesLeft struct {
1320+
IssueID int64
1321+
}
1322+
1323+
// IsErrDependenciesLeft checks if an error is a ErrDependenciesLeft.
1324+
func IsErrDependenciesLeft(err error) bool {
1325+
_, ok := err.(ErrDependenciesLeft)
1326+
return ok
1327+
}
1328+
1329+
func (err ErrDependenciesLeft) Error() string {
1330+
return fmt.Sprintf("issue has open dependencies [issue id: %d]", err.IssueID)
1331+
}
1332+
1333+
// ErrUnknownDependencyType represents an error where an unknown dependency type was passed
1334+
type ErrUnknownDependencyType struct {
1335+
Type DependencyType
1336+
}
1337+
1338+
// IsErrUnknownDependencyType checks if an error is ErrUnknownDependencyType
1339+
func IsErrUnknownDependencyType(err error) bool {
1340+
_, ok := err.(ErrUnknownDependencyType)
1341+
return ok
1342+
}
1343+
1344+
func (err ErrUnknownDependencyType) Error() string {
1345+
return fmt.Sprintf("unknown dependency type [type: %d]", err.Type)
1346+
}

models/issue.go

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,20 @@ func (issue *Issue) changeStatus(e *xorm.Session, doer *User, repo *Repository,
649649
if issue.IsClosed == isClosed {
650650
return nil
651651
}
652+
653+
// Check for open dependencies
654+
if isClosed && issue.Repo.IsDependenciesEnabled() {
655+
// only check if dependencies are enabled and we're about to close an issue, otherwise reopening an issue would fail when there are unsatisfied dependencies
656+
noDeps, err := IssueNoDependenciesLeft(issue)
657+
if err != nil {
658+
return err
659+
}
660+
661+
if !noDeps {
662+
return ErrDependenciesLeft{issue.ID}
663+
}
664+
}
665+
652666
issue.IsClosed = isClosed
653667
if isClosed {
654668
issue.ClosedUnix = util.TimeStampNow()
@@ -1283,7 +1297,7 @@ func getParticipantsByIssueID(e Engine, issueID int64) ([]*User, error) {
12831297
And("`comment`.type = ?", CommentTypeComment).
12841298
And("`user`.is_active = ?", true).
12851299
And("`user`.prohibit_login = ?", false).
1286-
Join("INNER", "user", "`user`.id = `comment`.poster_id").
1300+
Join("INNER", "`user`", "`user`.id = `comment`.poster_id").
12871301
Distinct("poster_id").
12881302
Find(&userIDs); err != nil {
12891303
return nil, fmt.Errorf("get poster IDs: %v", err)
@@ -1598,3 +1612,33 @@ func UpdateIssueDeadline(issue *Issue, deadlineUnix util.TimeStamp, doer *User)
15981612

15991613
return sess.Commit()
16001614
}
1615+
1616+
// Get Blocked By Dependencies, aka all issues this issue is blocked by.
1617+
func (issue *Issue) getBlockedByDependencies(e Engine) (issueDeps []*Issue, err error) {
1618+
return issueDeps, e.
1619+
Table("issue_dependency").
1620+
Select("issue.*").
1621+
Join("INNER", "issue", "issue.id = issue_dependency.dependency_id").
1622+
Where("issue_id = ?", issue.ID).
1623+
Find(&issueDeps)
1624+
}
1625+
1626+
// Get Blocking Dependencies, aka all issues this issue blocks.
1627+
func (issue *Issue) getBlockingDependencies(e Engine) (issueDeps []*Issue, err error) {
1628+
return issueDeps, e.
1629+
Table("issue_dependency").
1630+
Select("issue.*").
1631+
Join("INNER", "issue", "issue.id = issue_dependency.issue_id").
1632+
Where("dependency_id = ?", issue.ID).
1633+
Find(&issueDeps)
1634+
}
1635+
1636+
// BlockedByDependencies finds all Dependencies an issue is blocked by
1637+
func (issue *Issue) BlockedByDependencies() ([]*Issue, error) {
1638+
return issue.getBlockedByDependencies(x)
1639+
}
1640+
1641+
// BlockingDependencies returns all blocking dependencies, aka all other issues a given issue blocks
1642+
func (issue *Issue) BlockingDependencies() ([]*Issue, error) {
1643+
return issue.getBlockingDependencies(x)
1644+
}

0 commit comments

Comments
 (0)