Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92d2ba9889 | ||
|
|
ffb674669b | ||
|
|
4ff008e564 | ||
|
|
dfb5024dfb |
No files matched your search
@@ -0,0 +1,22 @@
|
|||||||
|
> **Correction (2026-09-23):** v1.27.2 did not fix every push notification template. Bloom, Ember, and Heritage still used the old commit ID path and can fail to render push notifications on Gitea 1.27.1+. Use v1.27.3 for the fix.
|
||||||
|
|
||||||
|
FEATURES
|
||||||
|
|
||||||
|
- THEMES (Aurora)
|
||||||
|
- Add `email-text` class to release template paragraphs for consistent typography with the rest of the theme
|
||||||
|
|
||||||
|
BUGFIXES
|
||||||
|
|
||||||
|
- THEMES
|
||||||
|
- Update push commit data paths in seven themes for Gitea 1.27.1 compatibility (`.ID` → `.UserCommit.GitCommit.ID`); see the correction above for the three remaining themes
|
||||||
|
- Replace `rgba()` colors with `#RRGGBBAA` hex notation across all 10 themes
|
||||||
|
|
||||||
|
DOCS
|
||||||
|
|
||||||
|
- Track Gitea 1.27.0, 1.27.1, and 1.27.2 compatibility
|
||||||
|
- Keep English and Simplified Chinese README and CONTRIBUTING files
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Full Changelog:** [v1.0.1...v1.27.2](https://github.com/KenanZhu/GiteaMailTemplates/compare/v1.0.1...v1.27.2)
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
FEATURES
|
||||||
|
|
||||||
|
- RELEASE
|
||||||
|
- Include English and Simplified Chinese README and CONTRIBUTING files in the release archives
|
||||||
|
- Use reviewed release notes in the publishing workflow
|
||||||
|
|
||||||
|
BUGFIXES
|
||||||
|
|
||||||
|
- THEMES (Bloom, Ember, Heritage)
|
||||||
|
- Fix pull request push notification commit links and abbreviated hashes for Gitea 1.27.1–1.27.3 by reading `.UserCommit.GitCommit.ID`
|
||||||
|
- CI
|
||||||
|
- Add a push notification regression test covering all 10 themes and run Go tests before packaging a release
|
||||||
|
|
||||||
|
DOCS
|
||||||
|
|
||||||
|
- Verify compatibility with Gitea 1.27.3; its mail templates, mailer, and locale files are unchanged from 1.27.2
|
||||||
|
- Correct the compatibility matrix to distinguish the affected v1.27.2 archive from this fixed release
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Full Changelog:** [v1.27.2...v1.27.3](https://github.com/KenanZhu/GiteaMailTemplates/compare/v1.27.2...v1.27.3)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
FEATURES
|
||||||
|
|
||||||
|
- COMPATIBILITY
|
||||||
|
- Add a Gitea 28.0.0-aligned release of all 10 themes and 11 mail types per theme
|
||||||
|
|
||||||
|
BUGFIXES
|
||||||
|
|
||||||
|
- THEMES (All 10)
|
||||||
|
- Replace the removed `FileSize` function with `FormatByteSize` in release-attachment emails, preventing Gitea 28.0.0 template rendering errors
|
||||||
|
- PREVIEW AND TESTS
|
||||||
|
- Match the preview's file-size function to Gitea 28.0.0 and render release attachments in the example data
|
||||||
|
- Add an all-theme regression test for release attachments and the removed function
|
||||||
|
|
||||||
|
DOCS
|
||||||
|
|
||||||
|
- Update the English and Simplified Chinese READMEs and compatibility matrix for Gitea 28.0.0
|
||||||
|
- Clarify that v28.0.0 requires Gitea 28.0.0; use v1.27.3 for Gitea 1.25.0–1.27.3
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Full Changelog:** [v1.27.3...v28.0.0](https://github.com/KenanZhu/GiteaMailTemplates/compare/v1.27.3...v28.0.0)
|
||||||
@@ -80,30 +80,12 @@ jobs:
|
|||||||
ROW="| **${NEW}** | ${TODAY} | ⏳ Pending Verification | TBD |"
|
ROW="| **${NEW}** | ${TODAY} | ⏳ Pending Verification | TBD |"
|
||||||
sed -i "${INSERT}a ${ROW}" COMPATIBILITY.md
|
sed -i "${INSERT}a ${ROW}" COMPATIBILITY.md
|
||||||
|
|
||||||
- name: COMPATIBILITY.md — latest verified note
|
- name: README.md — pending badge
|
||||||
if: steps.version.outputs.skip != 'true'
|
|
||||||
run: |
|
|
||||||
NEW="${{ steps.version.outputs.new_version }}"
|
|
||||||
# Update version inline on the line with TRACKER:LATEST-VERIFIED
|
|
||||||
sed -i "/TRACKER:LATEST-VERIFIED/s/Gitea [0-9.]*/Gitea ${NEW}/" COMPATIBILITY.md
|
|
||||||
|
|
||||||
- name: README.md — badge and latest tested
|
|
||||||
if: steps.version.outputs.skip != 'true'
|
if: steps.version.outputs.skip != 'true'
|
||||||
run: |
|
run: |
|
||||||
NEW="${{ steps.version.outputs.new_version }}"
|
NEW="${{ steps.version.outputs.new_version }}"
|
||||||
# Badge: update version, change label tested→pending, color blue→yellow
|
# Badge: update version, change label tested→pending, color blue→yellow
|
||||||
sed -i "/TRACKER:BADGE/s/%20[0-9a-z.-]*%20tested-blue/%20${NEW}%20pending-yellow/" README.md
|
sed -i "/TRACKER:BADGE/s/%20[0-9a-z.-]*%20tested-blue/%20${NEW}%20pending-yellow/" README.md
|
||||||
# Latest tested: update version on the TRACKER:LATEST-TESTED line
|
|
||||||
sed -i "/TRACKER:LATEST-TESTED/s/Gitea [0-9.]*/Gitea ${NEW}/" README.md
|
|
||||||
|
|
||||||
|
|
||||||
- name: README translations — latest tested
|
|
||||||
if: steps.version.outputs.skip != 'true'
|
|
||||||
run: |
|
|
||||||
NEW="${{ steps.version.outputs.new_version }}"
|
|
||||||
for f in docs/README.zh-CN.md; do
|
|
||||||
sed -i "/TRACKER:LATEST-TESTED/s/Gitea [0-9.]*/Gitea ${NEW}/" "$f"
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
if: steps.version.outputs.skip != 'true'
|
if: steps.version.outputs.skip != 'true'
|
||||||
@@ -117,21 +99,24 @@ jobs:
|
|||||||
|
|
||||||
This PR:
|
This PR:
|
||||||
- Updates the compatibility matrix in `COMPATIBILITY.md`
|
- Updates the compatibility matrix in `COMPATIBILITY.md`
|
||||||
- Updates version badges in `README.md` and translations
|
- Marks the new version as pending in the `README.md` badge
|
||||||
- Marks the new version as **⏳ Pending Verification**
|
- Marks the new version as **⏳ Pending Verification**
|
||||||
|
|
||||||
## Verification Checklist
|
## Verification Checklist
|
||||||
- [ ] Check [Gitea changelog](https://github.com/go-gitea/gitea/blob/main/CHANGELOG.md) for mail template changes
|
- [ ] Check [Gitea changelog](https://github.com/go-gitea/gitea/blob/main/CHANGELOG.md) for mail template changes
|
||||||
- [ ] Review diff of official templates: `git diff v${{ steps.version.outputs.current_version }}..v${{ steps.version.outputs.new_version }} -- templates/mail/ services/mailer/`
|
- [ ] Review diff of official templates: `git diff v${{ steps.version.outputs.current_version }}..v${{ steps.version.outputs.new_version }} -- templates/mail/ services/mailer/`
|
||||||
- [ ] Run `cd tools && go run . preview all` to confirm templates still render
|
- [ ] Run `cd tools && go run . preview all` to confirm templates still render
|
||||||
|
- [ ] Run `cd tools && go test ./...` to verify push-notification data paths
|
||||||
- [ ] Update status from ⏳ to ✅ (compatible) or ❌ (breaking) in COMPATIBILITY.md
|
- [ ] Update status from ⏳ to ✅ (compatible) or ❌ (breaking) in COMPATIBILITY.md
|
||||||
- [ ] Update the `Mail Template Changes` and `Breaking?` columns with accurate notes
|
- [ ] Update the `Mail Template Changes` and `Breaking?` columns with accurate notes
|
||||||
|
- [ ] After verification, update `TRACKER:LATEST-VERIFIED` and the English/Chinese `TRACKER:LATEST-TESTED` lines; switch the README badge from pending to tested
|
||||||
|
|
||||||
## Semantic tracking
|
## Semantic tracking
|
||||||
Once verified, update the tracked Gitea version (release numbers stay unchanged):
|
Once verified, update the tracked Gitea version:
|
||||||
- [ ] Update the parenthesized Gitea version on the active **Template Release** row in `COMPATIBILITY.md` (e.g. `v1.0.1(v${{ steps.version.outputs.new_version }})`)
|
- [ ] If templates changed, mark the top **Template Release** row `Unreleased` until the fix is tagged; if no change is needed, retain the verified release tag
|
||||||
- [ ] Update the README release line and badge to the new version
|
- [ ] Update the README release status and compatibility matrix to distinguish source fixes from published packages
|
||||||
- [ ] Tag a new release only if the template content itself changed — `git tag vX.Y.Z && git push origin vX.Y.Z` (the release workflow packages automatically)
|
- [ ] Write `.github/release-notes/vX.Y.Z.md` before tagging; the release workflow uses this file for the published notes
|
||||||
|
- [ ] Tag a new release when shipping template fixes — `git tag vX.Y.Z && git push origin vX.Y.Z` (the release workflow packages automatically)
|
||||||
labels: compatibility, automated
|
labels: compatibility, automated
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -16,6 +16,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: '1.21'
|
go-version: '1.21'
|
||||||
|
|
||||||
|
- name: Test — mail template data contexts
|
||||||
|
working-directory: tools
|
||||||
|
run: go test ./...
|
||||||
|
|
||||||
- name: Lint — render all templates
|
- name: Lint — render all templates
|
||||||
working-directory: tools
|
working-directory: tools
|
||||||
run: go run . preview all
|
run: go run . preview all
|
||||||
@@ -30,20 +34,25 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Verify release notes
|
||||||
|
run: test -s ".github/release-notes/${GITHUB_REF_NAME}.md"
|
||||||
|
|
||||||
- name: Package themes/
|
- name: Package themes/
|
||||||
run: |
|
run: |
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
ARCHIVE="gitea-mail-templates-${VERSION}"
|
ARCHIVE="gitea-mail-templates-${VERSION}"
|
||||||
mkdir -p "dist/${ARCHIVE}"
|
mkdir -p "dist/${ARCHIVE}/docs"
|
||||||
cp -r themes LICENSE README.md COMPATIBILITY.md "dist/${ARCHIVE}/"
|
cp -r themes LICENSE README.md CONTRIBUTING.md COMPATIBILITY.md "dist/${ARCHIVE}/"
|
||||||
|
cp docs/README.zh-CN.md docs/CONTRIBUTING.zh-CN.md "dist/${ARCHIVE}/docs/"
|
||||||
cd dist
|
cd dist
|
||||||
zip -r "${ARCHIVE}.zip" "${ARCHIVE}"
|
zip -r "${ARCHIVE}.zip" "${ARCHIVE}"
|
||||||
tar -czf "${ARCHIVE}.tar.gz" "${ARCHIVE}"
|
tar -czf "${ARCHIVE}.tar.gz" "${ARCHIVE}"
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v3
|
||||||
with:
|
with:
|
||||||
files: dist/*.zip,dist/*.tar.gz
|
files: dist/*.zip,dist/*.tar.gz
|
||||||
generate_release_notes: true
|
fail_on_unmatched_files: true
|
||||||
|
body_path: .github/release-notes/${{ github.ref_name }}.md
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -35,7 +35,7 @@ docs/ # Bilingual documentation (English + Simplified Chinese)
|
|||||||
|
|
||||||
### Template Files
|
### Template Files
|
||||||
- All `.tmpl` files use Go `html/template` syntax
|
- All `.tmpl` files use Go `html/template` syntax
|
||||||
- Must use only Gitea's built-in template functions: `AppUrl`, `DotEscape`, `QueryEscape`, `ShortSha`, `HTMLFormat`, `PathEscapeSegments`, `FileSize`
|
- Must use only Gitea 28's built-in template functions: `AppUrl`, `DotEscape`, `QueryEscape`, `ShortSha`, `HTMLFormat`, `PathEscapeSegments`, `FormatByteSize`
|
||||||
- Must use only official Gitea translation keys (`mail.*` namespace)
|
- Must use only official Gitea translation keys (`mail.*` namespace)
|
||||||
- Never reference `.DisplayName` in templates where the data context lacks it (collaborator, transfer, release, workflow_run, assigned, default)
|
- Never reference `.DisplayName` in templates where the data context lacks it (collaborator, transfer, release, workflow_run, assigned, default)
|
||||||
- Each style must have all 11 template types
|
- Each style must have all 11 template types
|
||||||
@@ -66,10 +66,11 @@ docs/ # Bilingual documentation (English + Simplified Chinese)
|
|||||||
|
|
||||||
## Versioning
|
## Versioning
|
||||||
|
|
||||||
- Release numbers stay on the project's own scheme; the supported Gitea version is appended in parentheses — `v1.0.1(v1.27.2)` means release `v1.0.1` tracks Gitea `1.27.2`
|
- Release tags identify actual downloadable packages; the compatibility matrix distinguishes released tags from source-only fixes
|
||||||
- The current release is **v1.0.1** (tracks Gitea 1.27.2); the quick-reference table in `COMPATIBILITY.md` lists it first — the tracker workflow updates that row by position
|
- The current release is **v28.0.0**, verified against Gitea 28.0.0. Gitea 28 removes `FileSize` in favor of `FormatByteSize`, so v28.0.0 is not compatible with Gitea 1.25.0–1.27.3; use v1.27.3 for those versions. The quick-reference table in `COMPATIBILITY.md` lists the active release first; the tracker workflow updates that row by position
|
||||||
- When a new Gitea version is verified compatible: update the parenthesized Gitea version in the active `COMPATIBILITY.md` row, plus the README release line and badge
|
- When a new Gitea version is checked: update the top `COMPATIBILITY.md` row and README badge; keep unreleased fixes distinct from the published release, and update verified/tested wording only after verification
|
||||||
- Tag a new release (`vX.Y.Z`) only when the template content itself changes — the release workflow packages automatically on tag push
|
- Tag a new release (`vX.Y.Z`) only when the template content itself changes — the release workflow packages automatically on tag push
|
||||||
|
- Before tagging, add `.github/release-notes/vX.Y.Z.md`; the release workflow validates the file, runs `go test ./...`, and publishes those reviewed notes with the archives
|
||||||
- Keep the `TRACKER:` markers in `COMPATIBILITY.md` / `README.md` adjacent to their rows so the automated workflow keeps parsing them
|
- Keep the `TRACKER:` markers in `COMPATIBILITY.md` / `README.md` adjacent to their rows so the automated workflow keeps parsing them
|
||||||
|
|
||||||
## Commit Conventions
|
## Commit Conventions
|
||||||
|
|||||||
+22
-13
@@ -7,23 +7,29 @@ This document tracks the compatibility between **Gitea Mail Templates** releases
|
|||||||
<!-- TRACKER:QUICK-REF-MAX OFFSET=3 -->
|
<!-- TRACKER:QUICK-REF-MAX OFFSET=3 -->
|
||||||
| Template Release | Min Gitea | Max Tested Gitea | Status |
|
| Template Release | Min Gitea | Max Tested Gitea | Status |
|
||||||
|-----------------|-----------|-----------------|--------|
|
|-----------------|-----------|-----------------|--------|
|
||||||
| **v1.0.1(v1.27.2)** | **1.25.0** | **1.27.2** | ✅ Active |
|
| **v28.0.0** | **28.0.0** | **28.0.0** | ✅ Active |
|
||||||
|
| **v1.27.3** | **1.25.0** | **1.27.3** | ✅ Superseded; release emails fail on Gitea 28.0.0 (`FileSize` removed) |
|
||||||
|
| **v1.27.2** | **1.25.0** | **1.27.3** | ⚠️ Push notices fail in Bloom, Ember, and Heritage on Gitea 1.27.1+ |
|
||||||
|
| **v1.0.1** | **1.25.0** | **1.27.0** | ✅ Superseded; push notices need newer release on 1.27.1+ |
|
||||||
| **v1.0.0** | **1.25.0** | **1.26.4** | ✅ Superseded |
|
| **v1.0.0** | **1.25.0** | **1.26.4** | ✅ Superseded |
|
||||||
|
|
||||||
> **Latest verified:** All 11 templates pass validation against Gitea 1.27.2 data contexts. <!-- TRACKER:LATEST-VERIFIED -->
|
> **Latest verified:** Release v28.0.0 passes the Gitea 28.0.0 mail-template, mailer-context, function, and translation-key source audit plus all-theme rendering tests. This release requires Gitea 28.0.0; use v1.27.3 for Gitea 1.25.0–1.27.3. <!-- TRACKER:LATEST-VERIFIED -->
|
||||||
|
|
||||||
## Versioning
|
## Versioning
|
||||||
|
|
||||||
From **1.27.1** onward, template releases are **semantically tracked** against Gitea: the release keeps its own number, and the supported Gitea version is appended in parentheses — `v1.0.1(v1.27.2)` means release `v1.0.1` is the version to use with Gitea `1.27.2`.
|
The release tag identifies the downloadable template package. The supported Gitea version may be appended in parentheses in this compatibility matrix; the parenthesized version is not a Git tag. An **unreleased** row describes fixes available in the repository but not yet in a downloadable release.
|
||||||
|
|
||||||
| Gitea version | Template release |
|
| Gitea version | Template release |
|
||||||
|---------------|------------------|
|
|---------------|------------------|
|
||||||
| 1.27.2 | **v1.0.1(v1.27.2)** |
|
| 28.0.0 | **v28.0.0**; older releases use the removed `FileSize` function in release emails |
|
||||||
| 1.27.1 | **v1.0.1(v1.27.1)** |
|
| 1.27.3 | **v1.27.3**; v1.27.2 has a push-notification issue in three themes |
|
||||||
|
| 1.27.2 | **v1.27.3**; v1.27.2 has the same issue |
|
||||||
|
| 1.27.1 | **v1.27.3**; v1.27.2 has the same issue |
|
||||||
|
|
||||||
- The [tracker workflow](.github/workflows/gitea-tracker.yml) opens a PR when a new Gitea release appears, marking it ⏳ Pending Verification.
|
- The [tracker workflow](.github/workflows/gitea-tracker.yml) opens a PR when a new Gitea release appears, marking it ⏳ Pending Verification.
|
||||||
- After verification, update the parenthesized Gitea version on the active **Template Release** row. A new release (`vX.Y.Z`) is only tagged when the template content itself changes — the [release workflow](.github/workflows/release.yml) packages the archive automatically on tag push.
|
- After verification, update the top **Template Release** row. Keep fixes on `main` marked **unreleased** until a new tag is published; the [release workflow](.github/workflows/release.yml) packages the archive on tag push.
|
||||||
- Releases before Gitea 1.27.1 predate semantic tracking and keep their plain version numbers in the matrix.
|
- The older `v1.0.1` tag predates the Gitea 1.27.1 push notification data fix and should not be used for Gitea 1.27.1 or newer.
|
||||||
|
- Gitea 28.0.0 replaces the mail-template `FileSize` function with `FormatByteSize`. The two functions are not interchangeable across these Gitea versions; use the matching template release.
|
||||||
|
|
||||||
## Check Your Gitea Version
|
## Check Your Gitea Version
|
||||||
|
|
||||||
@@ -38,8 +44,10 @@ gitea --version
|
|||||||
<!-- TRACKER:VERSION-INSERT OFFSET=2 -->
|
<!-- TRACKER:VERSION-INSERT OFFSET=2 -->
|
||||||
| Gitea | Release Date | Mail Template Changes | Breaking? |
|
| Gitea | Release Date | Mail Template Changes | Breaking? |
|
||||||
|-------|-------------|----------------------|-----------|
|
|-------|-------------|----------------------|-----------|
|
||||||
|
| **28.0.0** | 2026-09-29 | `FileSize` removed and `FormatByteSize` added; mail templates now have `mail/`-prefixed internal names and shared head/footer partials; workflow emails gain status-icon fields. Our custom template paths and referenced data fields remain valid. | **Yes** (release attachment formatting) |
|
||||||
|
| **1.27.3** | 2026-08-29 | No upstream mail template, mailer, or locale changes; an existing push-notification defect in three themes is fixed in template release v1.27.3 | No upstream break |
|
||||||
| **1.27.2** | 2026-08-14 | None — security + bug fixes | No |
|
| **1.27.2** | 2026-08-14 | None — security + bug fixes | No |
|
||||||
| **1.27.1** | 2026-07-27 | Fixed push commit data paths: .ID → .UserCommit.GitCommit.ID (#38467) | No |
|
| **1.27.1** | 2026-07-27 | Push commit data paths changed: .ID → .UserCommit.GitCommit.ID (#38467); older custom templates can fail on push notifications | Yes (old .ID paths) |
|
||||||
| **1.27.0** | 2026-07-13 | None — no mail template changes | No |
|
| **1.27.0** | 2026-07-13 | None — no mail template changes | No |
|
||||||
| **1.26.4** | 2026-06-21 | None — hotfix release | No |
|
| **1.26.4** | 2026-06-21 | None — hotfix release | No |
|
||||||
| **1.26.3** | 2026-06-20 | None — security release | No |
|
| **1.26.3** | 2026-06-20 | None — security release | No |
|
||||||
@@ -65,7 +73,7 @@ All 11 template types use only Gitea built-in variables and functions. Verified
|
|||||||
| `QueryEscape` | ≤ 1.21 | URL query encoding |
|
| `QueryEscape` | ≤ 1.21 | URL query encoding |
|
||||||
| `PathEscapeSegments` | ≤ 1.21 | Per-segment path encoding |
|
| `PathEscapeSegments` | ≤ 1.21 | Per-segment path encoding |
|
||||||
| `ShortSha` | ≤ 1.21 | Truncated commit hash |
|
| `ShortSha` | ≤ 1.21 | Truncated commit hash |
|
||||||
| `FileSize` | ≤ 1.21 | Human-readable file size |
|
| `FormatByteSize` | 28.0.0 | Human-readable IEC file size; replaces `FileSize` |
|
||||||
| `HTMLFormat` | ≤ 1.21 | Render string as safe HTML |
|
| `HTMLFormat` | ≤ 1.21 | Render string as safe HTML |
|
||||||
| `Iif` | ≤ 1.21 | Inline conditional |
|
| `Iif` | ≤ 1.21 | Inline conditional |
|
||||||
| `dict` | ≤ 1.21 | Build maps from key-value pairs |
|
| `dict` | ≤ 1.21 | Build maps from key-value pairs |
|
||||||
@@ -96,17 +104,18 @@ All 11 template types use only Gitea built-in variables and functions. Verified
|
|||||||
|
|
||||||
### Translation Keys
|
### Translation Keys
|
||||||
|
|
||||||
All templates use Gitea's official `mail.*` translation namespace. Keys are stable across Gitea 1.25+.
|
All templates use Gitea's official `mail.*` translation namespace. Every referenced key was checked against Gitea 28.0.0's English locale file.
|
||||||
|
|
||||||
## How Compatibility Is Verified
|
## How Compatibility Is Verified
|
||||||
|
|
||||||
1. **Automated lint** — CI renders all templates via `go run . preview all` on every push
|
1. **Automated lint** — CI renders all templates via `go run . preview all` on every push; the preview function map mirrors Gitea 28.0.0
|
||||||
2. **Source audit** — Template data contexts are cross-referenced against Gitea's `services/mailer/` package
|
2. **Source audit** — Template data contexts are cross-referenced against Gitea's `services/mailer/` package
|
||||||
3. **Release checklist** — Each release confirms the max-tested Gitea version in this file
|
3. **Regression tests** — Go tests render push notifications and release attachments in all 10 themes
|
||||||
|
4. **Release checklist** — Each release confirms the max-tested Gitea version in this file
|
||||||
|
|
||||||
## Automated Tracking
|
## Automated Tracking
|
||||||
|
|
||||||
A [workflow](.github/workflows/gitea-tracker.yml) runs daily (UTC 08:00) to detect new Gitea releases. When a new version is found, it automatically creates a PR updating the matrix and badges with a **⏳ Pending Verification** status. Manual trigger is also available via `workflow_dispatch`. Once verification passes, release the templates under the same version number (see [Versioning](#versioning)).
|
A [workflow](.github/workflows/gitea-tracker.yml) runs daily (UTC 08:00) to detect new Gitea releases. When a new version is found, it automatically creates a PR updating the matrix and badges with a **⏳ Pending Verification** status. Manual trigger is also available via `workflow_dispatch`. Once verification passes, update the compatibility matrix; publish a new template tag when template changes require a release (see [Versioning](#versioning)).
|
||||||
|
|
||||||
## Reporting Issues
|
## Reporting Issues
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
A curated collection of professionally designed, audience-driven email templates for self-hosted [Gitea](https://about.gitea.com) instances.
|
A curated collection of professionally designed, audience-driven email templates for self-hosted [Gitea](https://about.gitea.com) instances.
|
||||||
|
|
||||||
[](COMPATIBILITY.md) <!-- TRACKER:BADGE -->
|
[](COMPATIBILITY.md) <!-- TRACKER:BADGE -->
|
||||||
|
|
||||||
> **Release v1.0.1 — tracks Gitea 1.27.2 — 110 template files, 10 visual styles, 11 email types each**
|
> **Release v28.0.0 — verified with Gitea 28.0.0 — 110 template files, 10 visual styles, 11 email types each.**
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ A curated collection of professionally designed, audience-driven email templates
|
|||||||
|
|
||||||
Most self-hosted Gitea instances use the default plain email templates. This project provides **ready-to-deploy, visually polished alternatives** — each designed for a specific community or audience, so you can pick the one that feels right for your users.
|
Most self-hosted Gitea instances use the default plain email templates. This project provides **ready-to-deploy, visually polished alternatives** — each designed for a specific community or audience, so you can pick the one that feels right for your users.
|
||||||
|
|
||||||
Every template is a drop-in replacement. All Go template variables, translation keys, and Gitea data contexts are fully compatible. **No patches, no plugins, no forks required.**
|
The templates on `main` can replace Gitea's built-in mail templates without patches, plugins, or forks. Check the [compatibility matrix](COMPATIBILITY.md) before using a published archive; older releases may have version-specific limitations.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -163,10 +163,10 @@ gitea-mail-templates/
|
|||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
- **Gitea 1.25+** — matches the refactored mail template directory structure (v1.25)
|
- **Gitea 28.0.0** — use template release v28.0.0; earlier Gitea versions require an older package
|
||||||
- **Latest tested:** Gitea 1.27.2 <!-- TRACKER:LATEST-TESTED -->
|
- **Latest tested:** Gitea 28.0.0 <!-- TRACKER:LATEST-TESTED -->
|
||||||
- **Versioning:** releases are semantically tracked — Gitea 1.27.2 → template release v1.0.1(v1.27.2) (see [COMPATIBILITY.md](COMPATIBILITY.md))
|
- **Latest release:** [v28.0.0](https://github.com/KenanZhu/GiteaMailTemplates/releases/tag/v28.0.0) updates all 10 release-notification templates for Gitea's `FormatByteSize` function. Use [v1.27.3](https://github.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.27.3) for Gitea 1.25.0–1.27.3 (see [COMPATIBILITY.md](COMPATIBILITY.md))
|
||||||
- 100% variable-compatible with official Gitea templates — see [COMPATIBILITY.md](COMPATIBILITY.md) for the full matrix
|
- The current source uses Gitea's official template data paths — see [COMPATIBILITY.md](COMPATIBILITY.md) for release-specific limitations
|
||||||
- Uses only built-in Gitea template functions and official translation keys
|
- Uses only built-in Gitea template functions and official translation keys
|
||||||
- No custom template functions or locale patches required
|
- No custom template functions or locale patches required
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
为自托管 [Gitea](https://about.gitea.com) 实例精心设计、面向不同受众的邮件模板集合。
|
为自托管 [Gitea](https://about.gitea.com) 实例精心设计、面向不同受众的邮件模板集合。
|
||||||
|
|
||||||
> **110 个模板文件 — 10 种视觉风格,每种 11 种邮件类型**
|
> **发布版 v28.0.0 — 已通过 Gitea 28.0.0 兼容性检查 — 110 个模板文件、10 种视觉风格、每种 11 种邮件类型**
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
大多数自托管 Gitea 实例使用默认的纯文本邮件模板。本项目提供了**开箱即用、视觉精美的替代方案**——每种方案都针对特定社区或受众设计,您可以选择最适合您用户的风格。
|
大多数自托管 Gitea 实例使用默认的纯文本邮件模板。本项目提供了**开箱即用、视觉精美的替代方案**——每种方案都针对特定社区或受众设计,您可以选择最适合您用户的风格。
|
||||||
|
|
||||||
每个模板都是直接替换。所有 Go 模板变量、翻译键和 Gitea 数据上下文完全兼容。**无需补丁、无需插件、无需 fork。**
|
`main` 分支中的模板可直接替换 Gitea 内置邮件模板,**无需补丁、插件或 fork**。使用已发布的压缩包前,请先查看[兼容性说明](../COMPATIBILITY.md),了解旧版本的限制。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -78,10 +78,10 @@ cd tools && go run . dev
|
|||||||
|
|
||||||
## 兼容性
|
## 兼容性
|
||||||
|
|
||||||
- **Gitea 1.25+** — v1.25 引入的邮件模板目录结构
|
- **Gitea 28.0.0** — 使用模板发布版 v28.0.0;旧版 Gitea 请选用对应的旧版模板
|
||||||
- **最新测试:** Gitea 1.27.2<!-- TRACKER:LATEST-TESTED -->
|
- **最新测试:** Gitea 28.0.0<!-- TRACKER:LATEST-TESTED -->
|
||||||
- **版本号:** 发布版本语义化追踪 Gitea 版本 — Gitea 1.27.2 → 模板发布版 v1.0.1(v1.27.2)(详见 [COMPATIBILITY.md](COMPATIBILITY.md))
|
- **最新发布版:** [v28.0.0](https://github.com/KenanZhu/GiteaMailTemplates/releases/tag/v28.0.0) 已将全部 10 个主题的发布通知适配为 `FormatByteSize`;Gitea 1.25.0–1.27.3 请使用 [v1.27.3](https://github.com/KenanZhu/GiteaMailTemplates/releases/tag/v1.27.3)(详见[兼容性说明](../COMPATIBILITY.md))
|
||||||
- 与 Gitea 官方模板 100% 兼容 — 详见 [COMPATIBILITY.md](COMPATIBILITY.md)
|
- 当前源码使用 Gitea 官方模板的数据路径;各发布版的限制详见 [兼容性说明](../COMPATIBILITY.md)
|
||||||
|
|
||||||
## 许可证
|
## 许可证
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
{{if .Release.Attachments}}
|
{{if .Release.Attachments}}
|
||||||
{{range .Release.Attachments}}
|
{{range .Release.Attachments}}
|
||||||
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FileSize}})</a></li>
|
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FormatByteSize}})</a></li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -124,8 +124,8 @@
|
|||||||
<ul class="commit-list">
|
<ul class="commit-list">
|
||||||
{{range .Comment.Commits}}
|
{{range .Comment.Commits}}
|
||||||
<li class="commit-item">
|
<li class="commit-item">
|
||||||
<a href="{{$.Comment.Issue.PullRequest.BaseRepo.HTMLURL}}/commit/{{.ID}}" class="commit-link">
|
<a href="{{$.Comment.Issue.PullRequest.BaseRepo.HTMLURL}}/commit/{{.UserCommit.GitCommit.ID}}" class="commit-link">
|
||||||
{{ShortSha .ID.String}}
|
{{ShortSha .UserCommit.GitCommit.ID.String}}
|
||||||
</a> — {{.UserCommit.GitCommit.MessageTitle}}
|
</a> — {{.UserCommit.GitCommit.MessageTitle}}
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
{{if .Release.Attachments}}
|
{{if .Release.Attachments}}
|
||||||
{{range .Release.Attachments}}
|
{{range .Release.Attachments}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{.DownloadURL}}" target="_blank" style="color:#3b82f6;text-decoration:none;font-weight:500;">{{.Name}} ({{.Size | FileSize}})</a>
|
<a href="{{.DownloadURL}}" target="_blank" style="color:#3b82f6;text-decoration:none;font-weight:500;">{{.Name}} ({{.Size | FormatByteSize}})</a>
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
@@ -129,8 +129,8 @@
|
|||||||
<ul class="commit-list">
|
<ul class="commit-list">
|
||||||
{{range .Comment.Commits}}
|
{{range .Comment.Commits}}
|
||||||
<li class="commit-item">
|
<li class="commit-item">
|
||||||
<a href="{{$.Comment.Issue.PullRequest.BaseRepo.HTMLURL}}/commit/{{.ID}}" class="commit-link">
|
<a href="{{$.Comment.Issue.PullRequest.BaseRepo.HTMLURL}}/commit/{{.UserCommit.GitCommit.ID}}" class="commit-link">
|
||||||
{{ShortSha .ID.String}}
|
{{ShortSha .UserCommit.GitCommit.ID.String}}
|
||||||
</a> — {{.UserCommit.GitCommit.MessageTitle}}
|
</a> — {{.UserCommit.GitCommit.MessageTitle}}
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
{{if .Release.Attachments}}
|
{{if .Release.Attachments}}
|
||||||
{{range .Release.Attachments}}
|
{{range .Release.Attachments}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{.DownloadURL}}" target="_blank" style="color:#ea580c;text-decoration:none;font-weight:600;">{{.Name}} ({{.Size | FileSize}})</a>
|
<a href="{{.DownloadURL}}" target="_blank" style="color:#ea580c;text-decoration:none;font-weight:600;">{{.Name}} ({{.Size | FormatByteSize}})</a>
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
@@ -122,8 +122,8 @@
|
|||||||
<ul class="commit-list">
|
<ul class="commit-list">
|
||||||
{{range .Comment.Commits}}
|
{{range .Comment.Commits}}
|
||||||
<li class="commit-item">
|
<li class="commit-item">
|
||||||
<a href="{{$.Comment.Issue.PullRequest.BaseRepo.HTMLURL}}/commit/{{.ID}}" class="commit-link">
|
<a href="{{$.Comment.Issue.PullRequest.BaseRepo.HTMLURL}}/commit/{{.UserCommit.GitCommit.ID}}" class="commit-link">
|
||||||
{{ShortSha .ID.String}}
|
{{ShortSha .UserCommit.GitCommit.ID.String}}
|
||||||
</a> — {{.UserCommit.GitCommit.MessageTitle}}
|
</a> — {{.UserCommit.GitCommit.MessageTitle}}
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
{{if .Release.Attachments}}
|
{{if .Release.Attachments}}
|
||||||
{{range .Release.Attachments}}
|
{{range .Release.Attachments}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{.DownloadURL}}" target="_blank" style="color:#1e3a5f;text-decoration:none;font-weight:600;border-bottom:1px dotted #8b6914;">{{.Name}} ({{.Size | FileSize}})</a>
|
<a href="{{.DownloadURL}}" target="_blank" style="color:#1e3a5f;text-decoration:none;font-weight:600;border-bottom:1px dotted #8b6914;">{{.Name}} ({{.Size | FormatByteSize}})</a>
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@
|
|||||||
{{if .Release.Attachments}}
|
{{if .Release.Attachments}}
|
||||||
{{range .Release.Attachments}}
|
{{range .Release.Attachments}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{.DownloadURL}}" target="_blank">{{.Name}} ({{.Size | FileSize}})</a>
|
<a href="{{.DownloadURL}}" target="_blank">{{.Name}} ({{.Size | FormatByteSize}})</a>
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
{{if .Release.Attachments}}
|
{{if .Release.Attachments}}
|
||||||
{{range .Release.Attachments}}
|
{{range .Release.Attachments}}
|
||||||
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FileSize}})</a></li>
|
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FormatByteSize}})</a></li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
{{if .Release.Attachments}}
|
{{if .Release.Attachments}}
|
||||||
{{range .Release.Attachments}}
|
{{range .Release.Attachments}}
|
||||||
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FileSize}})</a></li>
|
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FormatByteSize}})</a></li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -101,7 +101,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
{{if .Release.Attachments}}
|
{{if .Release.Attachments}}
|
||||||
{{range .Release.Attachments}}
|
{{range .Release.Attachments}}
|
||||||
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FileSize}})</a></li>
|
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FormatByteSize}})</a></li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
{{if .Release.Attachments}}
|
{{if .Release.Attachments}}
|
||||||
{{range .Release.Attachments}}
|
{{range .Release.Attachments}}
|
||||||
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FileSize}})</a></li>
|
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FormatByteSize}})</a></li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
{{if .Release.Attachments}}
|
{{if .Release.Attachments}}
|
||||||
{{range .Release.Attachments}}
|
{{range .Release.Attachments}}
|
||||||
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FileSize}})</a></li>
|
<li><a href="{{.DownloadURL}}">{{.Name}} ({{.Size | FormatByteSize}})</a></li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -89,7 +89,9 @@
|
|||||||
"HTMLURL": "https://gitea.example.com/repo/project",
|
"HTMLURL": "https://gitea.example.com/repo/project",
|
||||||
"FullName": "acme/project"
|
"FullName": "acme/project"
|
||||||
},
|
},
|
||||||
"Attachments": []
|
"Attachments": [
|
||||||
|
{ "Name": "release-notes.txt", "DownloadURL": "https://gitea.example.com/repo/project/releases/download/v2.0.0/release-notes.txt", "Size": 1536 }
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"DisableDownloadSourceArchives": false
|
"DisableDownloadSourceArchives": false
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-4
@@ -15,7 +15,7 @@ var TemplateFuncs = template.FuncMap{
|
|||||||
"QueryEscape": url.QueryEscape,
|
"QueryEscape": url.QueryEscape,
|
||||||
"ShortSha": ShortSha,
|
"ShortSha": ShortSha,
|
||||||
"PathEscapeSegments": PathEscapeSegments,
|
"PathEscapeSegments": PathEscapeSegments,
|
||||||
"FileSize": FileSize,
|
"FormatByteSize": previewFormatByteSize,
|
||||||
"HTMLFormat": HTMLFormat,
|
"HTMLFormat": HTMLFormat,
|
||||||
"Dict": Dict,
|
"Dict": Dict,
|
||||||
"gt": Gt, // override built-in for JSON float64/int coercion
|
"gt": Gt, // override built-in for JSON float64/int coercion
|
||||||
@@ -41,8 +41,20 @@ func PathEscapeSegments(s string) string {
|
|||||||
return strings.Join(parts, "/")
|
return strings.Join(parts, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileSize formats a byte count as a human-readable string (e.g. "2.5 MB").
|
// previewFormatByteSize converts JSON fixture numbers to Gitea's int64 input type.
|
||||||
func FileSize(n int64) string {
|
func previewFormatByteSize(size any) (string, error) {
|
||||||
|
switch n := size.(type) {
|
||||||
|
case int64:
|
||||||
|
return FormatByteSize(n), nil
|
||||||
|
case float64:
|
||||||
|
return FormatByteSize(int64(n)), nil
|
||||||
|
default:
|
||||||
|
return "", fmt.Errorf("FormatByteSize: unsupported size type %T", size)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FormatByteSize mirrors Gitea 28's IEC attachment size formatting.
|
||||||
|
func FormatByteSize(n int64) string {
|
||||||
const unit = 1024
|
const unit = 1024
|
||||||
if n < unit {
|
if n < unit {
|
||||||
return fmt.Sprintf("%d B", n)
|
return fmt.Sprintf("%d B", n)
|
||||||
@@ -52,7 +64,7 @@ func FileSize(n int64) string {
|
|||||||
div *= unit
|
div *= unit
|
||||||
exp++
|
exp++
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%.1f %s", float64(n)/float64(div), []string{"KB", "MB", "GB", "TB"}[exp])
|
return fmt.Sprintf("%.1f %s", float64(n)/float64(div), []string{"KiB", "MiB", "GiB", "TiB"}[exp])
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTMLFormat substitutes %s/%d placeholders with HTML-escaped values.
|
// HTMLFormat substitutes %s/%d placeholders with HTML-escaped values.
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package preview
|
||||||
|
|
||||||
|
import (
|
||||||
|
"html/template"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gitea-mail-templates/tools/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
type testCommitID string
|
||||||
|
|
||||||
|
func (id testCommitID) String() string { return string(id) }
|
||||||
|
|
||||||
|
// Exercise the push-only branch with Gitea's nested commit data shape.
|
||||||
|
// The normal preview fixture has no commits, so it cannot catch stale .ID paths.
|
||||||
|
func TestPushCommitTemplates(t *testing.T) {
|
||||||
|
cfg, err := config.Load(filepath.Join("..", "data", "templates_config.json"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
const sha = "0123456789abcdef0123456789abcdef01234567"
|
||||||
|
data := cfg.Templates["default"].Params
|
||||||
|
data["ActionName"] = "push"
|
||||||
|
data["locale"] = Locale{}
|
||||||
|
comment := data["Comment"].(map[string]any)
|
||||||
|
comment["Commits"] = []any{map[string]any{
|
||||||
|
"UserCommit": map[string]any{
|
||||||
|
"GitCommit": map[string]any{
|
||||||
|
"ID": testCommitID(sha),
|
||||||
|
"MessageTitle": "Test push commit",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
markSafeHTML(data)
|
||||||
|
|
||||||
|
themesDir := filepath.Join("..", "..", "themes")
|
||||||
|
themes, err := os.ReadDir(themesDir)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, theme := range themes {
|
||||||
|
if !theme.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
t.Run(theme.Name(), func(t *testing.T) {
|
||||||
|
path := filepath.Join(themesDir, theme.Name(), "mail", "repo", "issue", "default.tmpl")
|
||||||
|
content, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
tmpl, err := template.New("push").Funcs(TemplateFuncs).Parse(string(content))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var html strings.Builder
|
||||||
|
if err := tmpl.Execute(&html, data); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !strings.Contains(html.String(), "/commit/"+sha) || !strings.Contains(html.String(), sha[:10]) {
|
||||||
|
t.Fatal("push commit link or abbreviated hash missing from rendered email")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package preview
|
||||||
|
|
||||||
|
import (
|
||||||
|
"html/template"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gitea-mail-templates/tools/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Gitea 28 removes FileSize, so render an attachment in every release theme.
|
||||||
|
func TestReleaseAttachmentsGitea28(t *testing.T) {
|
||||||
|
if _, ok := TemplateFuncs["FileSize"]; ok {
|
||||||
|
t.Fatal("FileSize is not available in Gitea 28 mail templates")
|
||||||
|
}
|
||||||
|
cfg, err := config.Load(filepath.Join("..", "data", "templates_config.json"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
data := cfg.Templates["release"].Params
|
||||||
|
data["locale"] = Locale{}
|
||||||
|
markSafeHTML(data)
|
||||||
|
|
||||||
|
themesDir := filepath.Join("..", "..", "themes")
|
||||||
|
themes, err := os.ReadDir(themesDir)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, theme := range themes {
|
||||||
|
if !theme.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
t.Run(theme.Name(), func(t *testing.T) {
|
||||||
|
content, err := os.ReadFile(filepath.Join(themesDir, theme.Name(), "mail", "repo", "release.tmpl"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
tmpl, err := template.New("release").Funcs(TemplateFuncs).Parse(string(content))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var rendered strings.Builder
|
||||||
|
if err := tmpl.Execute(&rendered, data); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !strings.Contains(rendered.String(), "release-notes.txt") || !strings.Contains(rendered.String(), "1.5 KiB") {
|
||||||
|
t.Fatal("release attachment or formatted size missing from email")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user