Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* PR and compare-page date groups build on the global commit-row component. */
:is(.github-pull-review, .github-compare) .pull-commit-group {
/* GitHub's commit history: a timeline of days, each a box of commit rows (the shared commit row) under "Commits on
<date>". The repository history, a pull request's commits and the compare page use it. */
.theme-commit-group {
position: relative;
margin-left: 16px;
padding: 0 0 16px 24px;
Expand Down Expand Up @@ -37,10 +38,14 @@
& .message {
min-width: 0;
}
& .commit-summary {
/* Inline text, so a title with an issue link wraps like a sentence; the shared row's inline-flex would stack its
pieces side by side. As specific as that rule, and loaded after it. */
& .message > .commit-summary {
display: inline;
font-size: 16px;
line-height: 24px;
font-weight: 600;
white-space: normal;
overflow-wrap: anywhere;
}
& .metadata {
Expand All @@ -67,7 +72,7 @@
}
}
@media (max-width: 767.98px) {
:is(.github-pull-review, .github-compare) .pull-commit-group {
.theme-commit-group {
margin-left: 8px;
padding-left: 16px;
& > ul > li.gitea-github-theme-commit {
Expand Down
16 changes: 16 additions & 0 deletions components/repository/commit-groups/commit-groups.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/* Commits grouped by the day they were committed, newest first as Forgejo lists them, each day a box of shared
commit rows. Called with the page context. */}}
{{$previousDate := ""}}
{{range .Commits}}
{{$time := .Committer.When}}{{if not $time}}{{$time = .Author.When}}{{end}}
{{$date := $time.Format "2006-01-02"}}
{{if ne $date $previousDate}}
{{if ne $previousDate ""}}</ul></article>{{end}}
{{$previousDate = $date}}
<article class="theme-commit-group">
<h3>{{svg "octicon-git-commit" 16}}Commits on {{$time.Format "Jan 2, 2006"}}</h3>
<ul class="gitea-github-theme-templates-commits-list">
{{end}}
{{template "repo/commit_list_item" dict "Commit" . "Page" $}}
{{end}}
{{if ne $previousDate ""}}</ul></article>{{end}}
1 change: 1 addition & 0 deletions scripts/assembleForgejo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ for (const directory of ["common", "project", "repository"]) {
}

for (const file of [
"commits.css",
"dashboard-lists.css",
"organization.css",
"profile-subpages.css",
Expand Down
23 changes: 22 additions & 1 deletion src/build-output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,24 @@ describe("Forgejo 15 native integration", () => {
);
});

it("shows the repository history as GitHub's Commits page grouped by day", () => {
const read = (...parts: string[]) => fs.readFileSync(path.join(ROOT_DIR, ...parts), "utf-8");
const commits = read("templates", "repo", "commits.tmpl");
expect(commits).toContain('{{ctx.Locale.Tr "repo.commits.commits"}}');
expect(commits).not.toContain('template "repo/sub_menu"');
expect(commits).toContain('"Items" "repo/commits_search_scope"');
for (const list of [
["templates", "repo", "commits_list.tmpl"],
["templates", "repo", "pulls", "commits_list.tmpl"],
])
expect(read(...list)).toContain('template "components/repository/commit-groups/commit-groups"');
expect(read("components", "repository", "commit-groups", "commit-groups.tmpl")).toContain(
'<article class="theme-commit-group">'
);
expect(fs.existsSync(path.join(ROOT_DIR, "public", "pull-commits.css"))).toBe(false);
expect(read("templates", "base", "component_assets.tmpl")).toContain("/css/components/pages/commits.css");
});

it("matches GitHub's repository About, visibility, and code-search details", () => {
const headerStyle = fs.readFileSync(path.join(ROOT_DIR, "styles", "templates", "repo", "header.ts"), "utf-8");
const headerTemplate = fs.readFileSync(path.join(ROOT_DIR, "templates", "repo", "home_header.tmpl"), "utf-8");
Expand Down Expand Up @@ -582,7 +600,10 @@ describe("Forgejo 15 native integration", () => {
path.join(ROOT_DIR, "templates", "repo", "latest_commit_row.tmpl"),
"utf-8"
);
const commitsListTemplate = fs.readFileSync(path.join(ROOT_DIR, "templates", "repo", "commits_list.tmpl"), "utf-8");
const commitsListTemplate = fs.readFileSync(
path.join(ROOT_DIR, "components", "repository", "commit-groups", "commit-groups.tmpl"),
"utf-8"
);
const commitSubjectTemplate = fs.readFileSync(
path.join(ROOT_DIR, "templates", "repo", "commit_message_subject.tmpl"),
"utf-8"
Expand Down
59 changes: 59 additions & 0 deletions styles/pages/commits.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* Commit history: GitHub's heading over a branch and search toolbar, then the commits grouped by day. Kept as a page
stylesheet, outside the size-limited theme files. */
.github-commits-title {
margin: 0 0 16px;
padding-bottom: 8px;
border-bottom: 1px solid var(--color-light-border);
font-size: 24px;
font-weight: 600;
line-height: 36px;
}

.github-commits-toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 16px;
}

.github-commits-ref,
.github-commits-actions,
.github-commits-search {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
}

.github-commits-ref .repo-path {
margin: 0;
font-size: 16px;
}

.github-commits-search .theme-search-field {
width: 260px;
}

.github-commits-renamed {
margin: 0 0 16px;
color: var(--color-text-light-1);
font-size: 12px;
}

@media (max-width: 767.98px) {
.github-commits-actions {
flex: 1 1 100%;
flex-wrap: wrap;
}

.github-commits-search {
flex: 1 1 100%;
}

.github-commits-search .theme-search-field {
flex: 1;
width: auto;
}
}
2 changes: 2 additions & 0 deletions templates/base/component_assets.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
<script src="{{AssetUrlPrefix}}/js/components/common/dropdown/dropdown.js" defer></script>
<script src="{{AssetUrlPrefix}}/js/components/common/dropdown/open-animation.js" defer></script>
<script src="{{AssetUrlPrefix}}/js/branch-selector.js" defer></script>
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/repository/commit-groups/commit-groups.css">
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/repository/label/list.css">
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/repository/milestone/milestone.css">
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/repository/results/results.css">
<script src="{{AssetUrlPrefix}}/js/components/repository/results/results.js" defer></script>
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/pages/commits.css">
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/pages/dashboard-lists.css">
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/pages/organization.css">
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/pages/profile-subpages.css">
Expand Down
36 changes: 36 additions & 0 deletions templates/repo/commits.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{/* GitHub's commit history: a "Commits" heading over a toolbar with the branch picker on the left and the search and
commit graph on the right, then the commits grouped by day. GitHub shows no commit, branch and tag counters here. */}}
{{template "base/head" .}}
{{$scope := ctx.Locale.Tr "repo.commits.search_branch"}}{{if .All}}{{$scope = ctx.Locale.Tr "repo.commits.search_all"}}{{end}}
<div role="main" aria-label="{{.Title}}" class="page-content repository commits github-commits">
<div class="ui container">
{{template "base/alert" .}}
<h1 class="github-commits-title">{{ctx.Locale.Tr "repo.commits.commits"}}</h1>
<div class="github-commits-toolbar">
<div class="github-commits-ref">
{{template "repo/branch_dropdown" dict "root" .}}
{{template "repo/filepath" .}}
</div>
<div class="github-commits-actions">
<form class="ignore-dirty github-commits-search" action="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/search" role="search">
{{template "components/common/search/search" dict "Kind" "icon" "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.commit_kind") "Label" (ctx.Locale.Tr "repo.commits.search.tooltip")}}
{{template "components/common/dropdown/dropdown" dict "Kind" "single" "Label" $scope "UpdateLabel" true "Items" "repo/commits_search_scope" "Data" .}}
</form>
<a href="{{.RepoLink}}/graph" class="button theme-control">{{svg "octicon-git-branch" 16}}{{ctx.Locale.Tr "repo.commit_graph"}}</a>
</div>
</div>
{{if .Commits}}
{{template "repo/commits_list" .}}
{{else}}
<div class="theme-empty">
{{svg "octicon-git-commit" 24}}
<h3>{{ctx.Locale.Tr "search.no_results"}}</h3>
</div>
{{end}}
{{if .OldFilename}}
<p class="github-commits-renamed">{{ctx.Locale.Tr "repo.commits.renamed_from" .OldFilename}} (<a href="{{.OldFilenameHistory}}">{{ctx.Locale.Tr "repo.commits.browse_further"}}</a>)</p>
{{end}}
{{template "base/paginate" .}}
</div>
</div>
{{template "base/footer" .}}
10 changes: 2 additions & 8 deletions templates/repo/commits_list.tmpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
{{/* GitHub-style commit history using the shared commit row. */}}
<div class="ui attached table segment commit-table">
<ul class="gitea-github-theme-templates-commits-list">
{{range .Commits}}
{{template "repo/commit_list_item" dict "Commit" . "Page" $}}
{{end}}
</ul>
</div>
{{/* GitHub groups a repository's history by day, as on a pull request's commits. */}}
{{template "components/repository/commit-groups/commit-groups" .}}
2 changes: 2 additions & 0 deletions templates/repo/commits_search_scope.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{template "components/common/dropdown/option" dict "Type" "radio" "Name" "all" "Value" "false" "Label" (ctx.Locale.Tr "repo.commits.search_branch") "Checked" (not .All)}}
{{template "components/common/dropdown/option" dict "Type" "radio" "Name" "all" "Value" "true" "Label" (ctx.Locale.Tr "repo.commits.search_all") "Checked" .All}}
1 change: 0 additions & 1 deletion templates/repo/diff/compare.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@
</div>

{{if $showDiffBox}}
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/pull-commits.css">
<div class="ui container">
{{if and .Commits (gt .CommitCount 0)}}
{{/* GitHub's summary row and its commits grouped by day. */}}
Expand Down
1 change: 0 additions & 1 deletion templates/repo/pulls/commits.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{template "base/head" .}}
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/pull-commits.css">
<div role="main" aria-label="{{.Title}}" class="page-content repository view issue pull commits github-pull-review">
<div class="ui container">
{{template "repo/issue/view_title" .}}
Expand Down
16 changes: 1 addition & 15 deletions templates/repo/pulls/commits_list.tmpl
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
{{/* Retain Forgejo's chronological grouping and reuse the history-row component. */}}
{{$previousDate := ""}}
{{range .Commits}}
{{$time := .Committer.When}}{{if not $time}}{{$time = .Author.When}}{{end}}
{{$date := $time.Format "2006-01-02"}}
{{if ne $date $previousDate}}
{{if ne $previousDate ""}}</ul></article>{{end}}
{{$previousDate = $date}}
<article class="pull-commit-group">
<h3>{{svg "octicon-git-commit" 16}}Commits on {{$time.Format "Jan 2, 2006"}}</h3>
<ul class="gitea-github-theme-templates-commits-list">
{{end}}
{{template "repo/commit_list_item" dict "Commit" . "Page" $}}
{{end}}
{{if ne $previousDate ""}}</ul></article>{{end}}
{{template "components/repository/commit-groups/commit-groups" .}}
Loading