Skip to content

Commit dc26370

Browse files
committed
Merge branch 'master' into create-user-system-defaults
2 parents dd8f66d + 3c140f0 commit dc26370

Some content is hidden

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

61 files changed

+360
-270
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,9 @@ release-sources: | $(DIST_DIRS)
646646
echo $(VERSION) > $(STORED_VERSION_FILE)
647647
# bsdtar needs a ^ to prevent matching subdirectories
648648
$(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./)
649-
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
649+
# use transform to a add a release-folder prefix; in bsdtar the transform parameter equivalent is -s
650+
$(eval TRANSFORM := $(shell tar --help | grep -q bsdtar && echo "-s '/^./gitea-src-$(VERSION)/'" || echo "--transform 's|^./|gitea-src-$(VERSION)/|'"))
651+
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
650652
rm -f $(STORED_VERSION_FILE)
651653

652654
.PHONY: release-docs

docs/content/doc/installation/with-docker.fr-fr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Vous devriez avoir une instance fonctionnelle de Gitea. Pour accèder à l'inter
4343

4444
## Named Volumes
4545

46-
Ce guide aboutira à une installation avec les données Gita et PostgreSQL stockées dans des volumes nommés. Cela permet une sauvegarde, une restauration et des mises à niveau en toute simplicité.
46+
Ce guide aboutira à une installation avec les données Gitea et PostgreSQL stockées dans des volumes nommés. Cela permet une sauvegarde, une restauration et des mises à niveau en toute simplicité.
4747

4848
### The Database
4949

models/issue.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,8 @@ func GetIssuesByIDs(issueIDs []int64) ([]*Issue, error) {
11941194
// IssuesOptions represents options of an issue.
11951195
type IssuesOptions struct {
11961196
db.ListOptions
1197-
RepoIDs []int64 // include all repos if empty
1197+
RepoID int64 // overwrites RepoCond if not 0
1198+
RepoCond builder.Cond
11981199
AssigneeID int64
11991200
PosterID int64
12001201
MentionedID int64
@@ -1285,15 +1286,15 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) {
12851286
sess.In("issue.id", opts.IssueIDs)
12861287
}
12871288

1288-
if len(opts.RepoIDs) > 0 {
1289-
applyReposCondition(sess, opts.RepoIDs)
1289+
if opts.RepoID != 0 {
1290+
opts.RepoCond = builder.Eq{"issue.repo_id": opts.RepoID}
1291+
}
1292+
if opts.RepoCond != nil {
1293+
sess.And(opts.RepoCond)
12901294
}
12911295

1292-
switch opts.IsClosed {
1293-
case util.OptionalBoolTrue:
1294-
sess.And("issue.is_closed=?", true)
1295-
case util.OptionalBoolFalse:
1296-
sess.And("issue.is_closed=?", false)
1296+
if !opts.IsClosed.IsNone() {
1297+
sess.And("issue.is_closed=?", opts.IsClosed.IsTrue())
12971298
}
12981299

12991300
if opts.AssigneeID > 0 {
@@ -1412,10 +1413,6 @@ func issuePullAccessibleRepoCond(repoIDstr string, userID int64, org *organizati
14121413
return cond
14131414
}
14141415

1415-
func applyReposCondition(sess *xorm.Session, repoIDs []int64) *xorm.Session {
1416-
return sess.In("issue.repo_id", repoIDs)
1417-
}
1418-
14191416
func applyAssigneeCondition(sess *xorm.Session, assigneeID int64) *xorm.Session {
14201417
return sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id").
14211418
And("issue_assignees.assignee_id = ?", assigneeID)

models/issue_label.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,9 @@ func (label *Label) CalOpenIssues() {
5757

5858
// CalOpenOrgIssues calculates the open issues of a label for a specific repo
5959
func (label *Label) CalOpenOrgIssues(repoID, labelID int64) {
60-
repoIDs := []int64{repoID}
61-
labelIDs := []int64{labelID}
62-
6360
counts, _ := CountIssuesByRepo(&IssuesOptions{
64-
RepoIDs: repoIDs,
65-
LabelIDs: labelIDs,
61+
RepoID: repoID,
62+
LabelIDs: []int64{labelID},
6663
})
6764

6865
for _, count := range counts {

models/issue_stopwatch.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,38 @@ func getStopwatch(ctx context.Context, userID, issueID int64) (sw *Stopwatch, ex
6666
return
6767
}
6868

69+
// UserIDCount is a simple coalition of UserID and Count
70+
type UserStopwatch struct {
71+
UserID int64
72+
StopWatches []*Stopwatch
73+
}
74+
75+
// GetUIDsAndNotificationCounts between the two provided times
76+
func GetUIDsAndStopwatch() ([]*UserStopwatch, error) {
77+
sws := []*Stopwatch{}
78+
if err := db.GetEngine(db.DefaultContext).Find(&sws); err != nil {
79+
return nil, err
80+
}
81+
if len(sws) == 0 {
82+
return []*UserStopwatch{}, nil
83+
}
84+
85+
lastUserID := int64(-1)
86+
res := []*UserStopwatch{}
87+
for _, sw := range sws {
88+
if lastUserID == sw.UserID {
89+
lastUserStopwatch := res[len(res)-1]
90+
lastUserStopwatch.StopWatches = append(lastUserStopwatch.StopWatches, sw)
91+
} else {
92+
res = append(res, &UserStopwatch{
93+
UserID: sw.UserID,
94+
StopWatches: []*Stopwatch{sw},
95+
})
96+
}
97+
}
98+
return res, nil
99+
}
100+
69101
// GetUserStopwatches return list of all stopwatches of a user
70102
func GetUserStopwatches(userID int64, listOptions db.ListOptions) ([]*Stopwatch, error) {
71103
sws := make([]*Stopwatch, 0, 8)

models/issue_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
user_model "code.gitea.io/gitea/models/user"
2222

2323
"github.com/stretchr/testify/assert"
24+
"xorm.io/builder"
2425
)
2526

2627
func TestIssue_ReplaceLabels(t *testing.T) {
@@ -157,7 +158,7 @@ func TestIssues(t *testing.T) {
157158
},
158159
{
159160
IssuesOptions{
160-
RepoIDs: []int64{1, 3},
161+
RepoCond: builder.In("repo_id", 1, 3),
161162
SortType: "oldest",
162163
ListOptions: db.ListOptions{
163164
Page: 1,
@@ -344,7 +345,7 @@ func TestGetRepoIDsForIssuesOptions(t *testing.T) {
344345
},
345346
{
346347
IssuesOptions{
347-
RepoIDs: []int64{1, 2},
348+
RepoCond: builder.In("repo_id", 1, 2),
348349
},
349350
[]int64{1, 2},
350351
},

models/migrations/migrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t
460460

461461
// Downgrading Gitea's database version not supported
462462
if int(v-minDBVersion) > len(migrations) {
463-
msg := fmt.Sprintf("Your database (migration version: %d) is for a newer Gita, you can not use the newer database for this old Gitea release (%d).", v, minDBVersion+len(migrations))
463+
msg := fmt.Sprintf("Your database (migration version: %d) is for a newer Gitea, you can not use the newer database for this old Gitea release (%d).", v, minDBVersion+len(migrations))
464464
msg += "\nGitea will exit to keep your database safe and unchanged. Please use the correct Gitea release, do not change the migration version manually (incorrect manual operation may lose data)."
465465
if !setting.IsProd {
466466
msg += fmt.Sprintf("\nIf you are in development and really know what you're doing, you can force changing the migration version by executing: UPDATE version SET version=%d WHERE id=1;", minDBVersion+len(migrations))

modules/context/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ func RepoRefForAPI(next http.Handler) http.Handler {
362362
return
363363
}
364364
ctx.Repo.Commit = commit
365+
ctx.Repo.TreePath = ctx.Params("*")
365366
return
366367
}
367368

modules/eventsource/manager_run.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import (
99
"time"
1010

1111
"code.gitea.io/gitea/models"
12+
"code.gitea.io/gitea/modules/convert"
1213
"code.gitea.io/gitea/modules/graceful"
14+
"code.gitea.io/gitea/modules/json"
1315
"code.gitea.io/gitea/modules/log"
1416
"code.gitea.io/gitea/modules/process"
1517
"code.gitea.io/gitea/modules/setting"
@@ -80,6 +82,31 @@ loop:
8082
})
8183
}
8284
then = now
85+
86+
if setting.Service.EnableTimetracking {
87+
usersStopwatches, err := models.GetUIDsAndStopwatch()
88+
if err != nil {
89+
log.Error("Unable to get GetUIDsAndStopwatch: %v", err)
90+
return
91+
}
92+
93+
for _, userStopwatches := range usersStopwatches {
94+
apiSWs, err := convert.ToStopWatches(userStopwatches.StopWatches)
95+
if err != nil {
96+
log.Error("Unable to APIFormat stopwatches: %v", err)
97+
continue
98+
}
99+
dataBs, err := json.Marshal(apiSWs)
100+
if err != nil {
101+
log.Error("Unable to marshal stopwatches: %v", err)
102+
continue
103+
}
104+
m.SendMessage(userStopwatches.UserID, &Event{
105+
Name: "stopwatches",
106+
Data: string(dataBs),
107+
})
108+
}
109+
}
83110
}
84111
}
85112
m.UnregisterAll()

modules/git/diff.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ const (
2828
)
2929

3030
// GetRawDiff dumps diff results of repository in given commit ID to io.Writer.
31-
func GetRawDiff(ctx context.Context, repoPath, commitID string, diffType RawDiffType, writer io.Writer) error {
32-
return GetRawDiffForFile(ctx, repoPath, "", commitID, diffType, "", writer)
31+
func GetRawDiff(repo *Repository, commitID string, diffType RawDiffType, writer io.Writer) error {
32+
return GetRepoRawDiffForFile(repo, "", commitID, diffType, "", writer)
3333
}
3434

3535
// GetReverseRawDiff dumps the reverse diff results of repository in given commit ID to io.Writer.
@@ -46,17 +46,6 @@ func GetReverseRawDiff(ctx context.Context, repoPath, commitID string, writer io
4646
return nil
4747
}
4848

49-
// GetRawDiffForFile dumps diff results of file in given commit ID to io.Writer.
50-
func GetRawDiffForFile(ctx context.Context, repoPath, startCommit, endCommit string, diffType RawDiffType, file string, writer io.Writer) error {
51-
repo, closer, err := RepositoryFromContextOrOpen(ctx, repoPath)
52-
if err != nil {
53-
return fmt.Errorf("RepositoryFromContextOrOpen: %v", err)
54-
}
55-
defer closer.Close()
56-
57-
return GetRepoRawDiffForFile(repo, startCommit, endCommit, diffType, file, writer)
58-
}
59-
6049
// GetRepoRawDiffForFile dumps diff results of file in given commit ID to io.Writer according given repository
6150
func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diffType RawDiffType, file string, writer io.Writer) error {
6251
commit, err := repo.GetCommit(endCommit)

modules/indexer/issues/indexer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func populateIssueIndexer(ctx context.Context) {
321321
// UpdateRepoIndexer add/update all issues of the repositories
322322
func UpdateRepoIndexer(repo *repo_model.Repository) {
323323
is, err := models.Issues(&models.IssuesOptions{
324-
RepoIDs: []int64{repo.ID},
324+
RepoID: repo.ID,
325325
IsClosed: util.OptionalBoolNone,
326326
IsPull: util.OptionalBoolNone,
327327
})

modules/sync/unique_queue.go

Lines changed: 0 additions & 104 deletions
This file was deleted.

options/locale/locale_bg-BG.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ loading=Зареждане…
7272
error404=Страницата, която се опитвате да достъпите, <strong>не съществува</strong> или <strong>не сте оторизирани</strong> да я достъпите.
7373

7474

75+
7576
[error]
7677

7778
[startpage]

options/locale/locale_cs-CZ.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ error404=Stránka, kterou se snažíte zobrazit, buď <strong>neexistuje</strong
8686

8787
never=Nikdy
8888

89+
8990
[error]
9091
missing_csrf=Špatný požadavek: Neexistuje CSRF token
9192

options/locale/locale_de-DE.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ error404=Die Seite, die du gerade versuchst aufzurufen, <strong>existiert entwed
103103

104104
never=Niemals
105105

106+
106107
[error]
107108
occurred=Ein Fehler ist aufgetreten
108109
report_message=Wenn du dir sicher bist, dass dies ein Fehler von Gitea ist, suche bitte auf <a href="https://github.com/go-gitea/gitea/issues">GitHub</a> nach diesem Fehler und erstelle gegebenenfalls ein neues Issue.

options/locale/locale_el-GR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ error404=Η σελίδα που προσπαθείτε να φτάσετε εί
105105

106106
never=Ποτέ
107107

108+
108109
[error]
109110
occurred=Παρουσιάστηκε ένα σφάλμα
110111
report_message=Αν είστε σίγουροι ότι πρόκειται για ένα πρόβλημα στο Gitea, παρακαλώ αναζητήστε στα ζητήματα στο <a href="https://github.com/go-gitea/gitea/issues" target="_blank">GitHub</a> ή ανοίξτε ένα νέο ζήτημα εάν είναι απαραίτητο.

options/locale/locale_en-US.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ line_unicode = `This line has hidden unicode characters`
10411041
escape_control_characters = Escape
10421042
unescape_control_characters = Unescape
10431043
file_copy_permalink = Copy Permalink
1044+
view_git_blame = View Git Blame
10441045
video_not_supported_in_browser = Your browser does not support the HTML5 'video' tag.
10451046
audio_not_supported_in_browser = Your browser does not support the HTML5 'audio' tag.
10461047
stored_lfs = Stored with Git LFS
@@ -3088,7 +3089,7 @@ settings.link = Link this package to a repository
30883089
settings.link.description = If you link a package with a repository, the package is listed in the repository's package list.
30893090
settings.link.select = Select Repository
30903091
settings.link.button = Update Repository Link
3091-
settings.link.success = Repository link was successfully updated.
3092+
settings.link.success = Repository link was successfully updated.
30923093
settings.link.error = Failed to update repository link.
30933094
settings.delete = Delete package
30943095
settings.delete.description = Deleting a package is permanent and cannot be undone.

0 commit comments

Comments
 (0)