Skip to content

Commit 0289193

Browse files
authored
Merge branch 'main' into fix-sync-fork
2 parents 3ec97d0 + 6073e2f commit 0289193

File tree

25 files changed

+269
-174
lines changed

25 files changed

+269
-174
lines changed

models/issues/stopwatch.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ func (s Stopwatch) Seconds() int64 {
4646
return int64(timeutil.TimeStampNow() - s.CreatedUnix)
4747
}
4848

49-
// Duration returns a human-readable duration string based on local server time
50-
func (s Stopwatch) Duration() string {
51-
return util.SecToTime(s.Seconds())
52-
}
53-
5449
func getStopwatch(ctx context.Context, userID, issueID int64) (sw *Stopwatch, exists bool, err error) {
5550
sw = new(Stopwatch)
5651
exists, err = db.GetEngine(ctx).
@@ -201,7 +196,7 @@ func FinishIssueStopwatch(ctx context.Context, user *user_model.User, issue *Iss
201196
Doer: user,
202197
Issue: issue,
203198
Repo: issue.Repo,
204-
Content: util.SecToTime(timediff),
199+
Content: util.SecToHours(timediff),
205200
Type: CommentTypeStopTracking,
206201
TimeID: tt.ID,
207202
}); err != nil {

modules/git/diff.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diff
6464
} else if commit.ParentCount() == 0 {
6565
cmd.AddArguments("show").AddDynamicArguments(endCommit).AddDashesAndList(files...)
6666
} else {
67-
c, _ := commit.Parent(0)
67+
c, err := commit.Parent(0)
68+
if err != nil {
69+
return err
70+
}
6871
cmd.AddArguments("diff", "-M").AddDynamicArguments(c.ID.String(), endCommit).AddDashesAndList(files...)
6972
}
7073
case RawDiffPatch:
@@ -74,7 +77,10 @@ func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diff
7477
} else if commit.ParentCount() == 0 {
7578
cmd.AddArguments("format-patch", "--no-signature", "--stdout", "--root").AddDynamicArguments(endCommit).AddDashesAndList(files...)
7679
} else {
77-
c, _ := commit.Parent(0)
80+
c, err := commit.Parent(0)
81+
if err != nil {
82+
return err
83+
}
7884
query := fmt.Sprintf("%s...%s", endCommit, c.ID.String())
7985
cmd.AddArguments("format-patch", "--no-signature", "--stdout").AddDynamicArguments(query).AddDashesAndList(files...)
8086
}

modules/git/repo_branch_gogit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (repo *Repository) IsBranchExist(name string) bool {
5757

5858
// GetBranches returns branches from the repository, skipping "skip" initial branches and
5959
// returning at most "limit" branches, or all branches if "limit" is 0.
60-
// Branches are returned with sort of `-commiterdate` as the nogogit
60+
// Branches are returned with sort of `-committerdate` as the nogogit
6161
// implementation. This requires full fetch, sort and then the
6262
// skip/limit applies later as gogit returns in undefined order.
6363
func (repo *Repository) GetBranchNames(skip, limit int) ([]string, int, error) {

modules/templates/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func NewFuncMap() template.FuncMap {
6969
// time / number / format
7070
"FileSize": base.FileSize,
7171
"CountFmt": countFmt,
72-
"Sec2Time": util.SecToTime,
72+
"Sec2Time": util.SecToHours,
7373

7474
"TimeEstimateString": timeEstimateString,
7575

modules/util/sec_to_time.go

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,17 @@ import (
88
"strings"
99
)
1010

11-
// SecToTime converts an amount of seconds to a human-readable string. E.g.
12-
// 66s -> 1 minute 6 seconds
13-
// 52410s -> 14 hours 33 minutes
14-
// 563418 -> 6 days 12 hours
15-
// 1563418 -> 2 weeks 4 days
16-
// 3937125s -> 1 month 2 weeks
17-
// 45677465s -> 1 year 6 months
18-
func SecToTime(durationVal any) string {
11+
// SecToHours converts an amount of seconds to a human-readable hours string.
12+
// This is stable for planning and managing timesheets.
13+
// Here it only supports hours and minutes, because a work day could contain 6 or 7 or 8 hours.
14+
func SecToHours(durationVal any) string {
1915
duration, _ := ToInt64(durationVal)
20-
21-
formattedTime := ""
22-
23-
// The following four variables are calculated by taking
24-
// into account the previously calculated variables, this avoids
25-
// pitfalls when using remainders. As that could lead to incorrect
26-
// results when the calculated number equals the quotient number.
27-
remainingDays := duration / (60 * 60 * 24)
28-
years := remainingDays / 365
29-
remainingDays -= years * 365
30-
months := remainingDays * 12 / 365
31-
remainingDays -= months * 365 / 12
32-
weeks := remainingDays / 7
33-
remainingDays -= weeks * 7
34-
days := remainingDays
35-
36-
// The following three variables are calculated without depending
37-
// on the previous calculated variables.
38-
hours := (duration / 3600) % 24
16+
hours := duration / 3600
3917
minutes := (duration / 60) % 60
40-
seconds := duration % 60
4118

42-
// Extract only the relevant information of the time
43-
// If the time is greater than a year, it makes no sense to display seconds.
44-
switch {
45-
case years > 0:
46-
formattedTime = formatTime(years, "year", formattedTime)
47-
formattedTime = formatTime(months, "month", formattedTime)
48-
case months > 0:
49-
formattedTime = formatTime(months, "month", formattedTime)
50-
formattedTime = formatTime(weeks, "week", formattedTime)
51-
case weeks > 0:
52-
formattedTime = formatTime(weeks, "week", formattedTime)
53-
formattedTime = formatTime(days, "day", formattedTime)
54-
case days > 0:
55-
formattedTime = formatTime(days, "day", formattedTime)
56-
formattedTime = formatTime(hours, "hour", formattedTime)
57-
case hours > 0:
58-
formattedTime = formatTime(hours, "hour", formattedTime)
59-
formattedTime = formatTime(minutes, "minute", formattedTime)
60-
default:
61-
formattedTime = formatTime(minutes, "minute", formattedTime)
62-
formattedTime = formatTime(seconds, "second", formattedTime)
63-
}
19+
formattedTime := ""
20+
formattedTime = formatTime(hours, "hour", formattedTime)
21+
formattedTime = formatTime(minutes, "minute", formattedTime)
6422

6523
// The formatTime() function always appends a space at the end. This will be trimmed
6624
return strings.TrimRight(formattedTime, " ")
@@ -76,6 +34,5 @@ func formatTime(value int64, name, formattedTime string) string {
7634
} else if value > 1 {
7735
formattedTime = fmt.Sprintf("%s%d %ss ", formattedTime, value, name)
7836
}
79-
8037
return formattedTime
8138
}

modules/util/sec_to_time_test.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,17 @@ import (
99
"github.com/stretchr/testify/assert"
1010
)
1111

12-
func TestSecToTime(t *testing.T) {
12+
func TestSecToHours(t *testing.T) {
1313
second := int64(1)
1414
minute := 60 * second
1515
hour := 60 * minute
1616
day := 24 * hour
17-
year := 365 * day
1817

19-
assert.Equal(t, "1 minute 6 seconds", SecToTime(minute+6*second))
20-
assert.Equal(t, "1 hour", SecToTime(hour))
21-
assert.Equal(t, "1 hour", SecToTime(hour+second))
22-
assert.Equal(t, "14 hours 33 minutes", SecToTime(14*hour+33*minute+30*second))
23-
assert.Equal(t, "6 days 12 hours", SecToTime(6*day+12*hour+30*minute+18*second))
24-
assert.Equal(t, "2 weeks 4 days", SecToTime((2*7+4)*day+2*hour+16*minute+58*second))
25-
assert.Equal(t, "4 weeks", SecToTime(4*7*day))
26-
assert.Equal(t, "4 weeks 1 day", SecToTime((4*7+1)*day))
27-
assert.Equal(t, "1 month 2 weeks", SecToTime((6*7+3)*day+13*hour+38*minute+45*second))
28-
assert.Equal(t, "11 months", SecToTime(year-25*day))
29-
assert.Equal(t, "1 year 5 months", SecToTime(year+163*day+10*hour+11*minute+5*second))
18+
assert.Equal(t, "1 minute", SecToHours(minute+6*second))
19+
assert.Equal(t, "1 hour", SecToHours(hour))
20+
assert.Equal(t, "1 hour", SecToHours(hour+second))
21+
assert.Equal(t, "14 hours 33 minutes", SecToHours(14*hour+33*minute+30*second))
22+
assert.Equal(t, "156 hours 30 minutes", SecToHours(6*day+12*hour+30*minute+18*second))
23+
assert.Equal(t, "98 hours 16 minutes", SecToHours(4*day+2*hour+16*minute+58*second))
24+
assert.Equal(t, "672 hours", SecToHours(4*7*day))
3025
}

options/gitignore/Node

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ dist
104104
.temp
105105
.cache
106106

107+
# vitepress build output
108+
**/.vitepress/dist
109+
110+
# vitepress cache directory
111+
**/.vitepress/cache
112+
107113
# Docusaurus cache and generated files
108114
.docusaurus
109115

options/gitignore/Python

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,8 @@ cython_debug/
167167
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168168
#.idea/
169169

170+
# Ruff stuff:
171+
.ruff_cache/
172+
170173
# PyPI configuration file
171174
.pypirc

options/gitignore/Rust

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
debug/
44
target/
55

6-
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7-
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8-
Cargo.lock
9-
106
# These are backup files generated by rustfmt
117
**/*.rs.bk
128

options/locale/locale_ja-JP.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,8 @@ fork_to_different_account=別のアカウントにフォークする
10341034
fork_visibility_helper=フォークしたリポジトリの公開/非公開は変更できません。
10351035
fork_branch=フォークにクローンされるブランチ
10361036
all_branches=すべてのブランチ
1037+
view_all_branches=すべてのブランチを表示
1038+
view_all_tags=すべてのタグを表示
10371039
fork_no_valid_owners=このリポジトリには有効なオーナーがいないため、フォークできません。
10381040
fork.blocked_user=リポジトリのオーナーがあなたをブロックしているため、リポジトリをフォークできません。
10391041
use_template=このテンプレートを使用
@@ -1108,6 +1110,7 @@ delete_preexisting_success=%s の未登録ファイルを削除しました
11081110
blame_prior=この変更より前のBlameを表示
11091111
blame.ignore_revs=<a href="%s">.git-blame-ignore-revs</a> で指定されたリビジョンは除外しています。 これを迂回して通常のBlame表示を見るには <a href="%s">ここ</a>をクリック。
11101112
blame.ignore_revs.failed=<a href="%s">.git-blame-ignore-revs</a> によるリビジョンの無視は失敗しました。
1113+
user_search_tooltip=最大30人までのユーザーを表示
11111114

11121115

11131116
transfer.accept=移転を承認
@@ -1226,6 +1229,7 @@ create_new_repo_command=コマンドラインから新しいリポジトリを
12261229
push_exist_repo=コマンドラインから既存のリポジトリをプッシュ
12271230
empty_message=このリポジトリの中には何もありません。
12281231
broken_message=このリポジトリの基礎となる Git のデータを読み取れません。このインスタンスの管理者に相談するか、このリポジトリを削除してください。
1232+
no_branch=このリポジトリにはブランチがありません。
12291233

12301234
code=コード
12311235
code.desc=ソースコード、ファイル、コミット、ブランチにアクセス。
@@ -1523,6 +1527,8 @@ issues.filter_assignee=担当者
15231527
issues.filter_assginee_no_select=すべての担当者
15241528
issues.filter_assginee_no_assignee=担当者なし
15251529
issues.filter_poster=作成者
1530+
issues.filter_user_placeholder=ユーザーを検索
1531+
issues.filter_user_no_select=すべてのユーザー
15261532
issues.filter_type=タイプ
15271533
issues.filter_type.all_issues=すべてのイシュー
15281534
issues.filter_type.assigned_to_you=自分が担当
@@ -1674,13 +1680,16 @@ issues.timetracker_timer_manually_add=時間を追加
16741680

16751681
issues.time_estimate_set=見積時間を設定
16761682
issues.time_estimate_display=見積時間: %s
1683+
issues.change_time_estimate_at=が見積時間を <b>%[1]s</b> に変更 %[2]s
16771684
issues.remove_time_estimate_at=が見積時間を削除 %s
16781685
issues.time_estimate_invalid=見積時間のフォーマットが不正です
16791686
issues.start_tracking_history=が作業を開始 %s
16801687
issues.tracker_auto_close=タイマーは、このイシューがクローズされると自動的に終了します
16811688
issues.tracking_already_started=`<a href="%s">別のイシュー</a>で既にタイムトラッキングを開始しています!`
1689+
issues.stop_tracking_history=が <b>%[1]s</b> の作業を終了 %[2]s
16821690
issues.cancel_tracking_history=`がタイムトラッキングを中止 %s`
16831691
issues.del_time=このタイムログを削除
1692+
issues.add_time_history=が作業時間 <b>%[1]s</b> を追加 %[2]s
16841693
issues.del_time_history=`が作業時間を削除 %s`
16851694
issues.add_time_manually=時間の手入力
16861695
issues.add_time_hours=時間
@@ -1935,6 +1944,8 @@ pulls.delete.title=このプルリクエストを削除しますか?
19351944
pulls.delete.text=本当にこのプルリクエストを削除しますか? (これはすべてのコンテンツを完全に削除します。 保存しておきたい場合は、代わりにクローズすることを検討してください)
19361945

19371946
pulls.recently_pushed_new_branches=%[2]s 、あなたはブランチ <strong>%[1]s</strong> にプッシュしました
1947+
pulls.upstream_diverging_prompt_behind_1=このブランチは %[2]s よりも %[1]d コミット遅れています
1948+
pulls.upstream_diverging_prompt_behind_n=このブランチは %[2]s よりも %[1]d コミット遅れています
19381949
pulls.upstream_diverging_prompt_base_newer=ベースブランチ %s に新しい変更があります
19391950
pulls.upstream_diverging_merge=フォークを同期
19401951

@@ -2618,6 +2629,7 @@ release.new_release=新しいリリース
26182629
release.draft=下書き
26192630
release.prerelease=プレリリース
26202631
release.stable=安定版
2632+
release.latest=最新
26212633
release.compare=比較
26222634
release.edit=編集
26232635
release.ahead.commits=<strong>%d</strong>件のコミット
@@ -2846,6 +2858,7 @@ teams.invite.title=あなたは組織 <strong>%[2]s</strong> 内のチーム <st
28462858
teams.invite.by=%s からの招待
28472859
teams.invite.description=下のボタンをクリックしてチームに参加してください。
28482860

2861+
view_as_role=表示: %s
28492862
view_as_public_hint=READMEを公開ユーザーとして見ています。
28502863
view_as_member_hint=READMEをこの組織のメンバーとして見ています。
28512864

@@ -3547,6 +3560,7 @@ conda.install=Conda を使用してパッケージをインストールするに
35473560
container.details.type=イメージタイプ
35483561
container.details.platform=プラットフォーム
35493562
container.pull=コマンドラインでイメージを取得します:
3563+
container.digest=ダイジェスト
35503564
container.multi_arch=OS / アーキテクチャ
35513565
container.layers=イメージレイヤー
35523566
container.labels=ラベル

0 commit comments

Comments
 (0)