mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-03-29 10:29:57 +00:00
Implement Branch in Status Command (#1057)
Some checks failed
GHCR - Development Branches / ghcr-publish (push) Failing after 32s
Docker Hub - Develop / docker-latest (push) Failing after 34s
Tests / Application Service Integration tests (push) Failing after 13m52s
Tests / Integration tests (push) Failing after 13m54s
Tests / Unit tests (push) Failing after 13m57s
Tests / Build & Lint (push) Failing after 13m59s
Some checks failed
GHCR - Development Branches / ghcr-publish (push) Failing after 32s
Docker Hub - Develop / docker-latest (push) Failing after 34s
Tests / Application Service Integration tests (push) Failing after 13m52s
Tests / Integration tests (push) Failing after 13m54s
Tests / Unit tests (push) Failing after 13m57s
Tests / Build & Lint (push) Failing after 13m59s
* Implement Branch in Status Command So now that we have dev branch containers and Cat checked Gnuxies Bot ye Huston we have a problem ala #1056.
This commit is contained in:
5
.changeset/wild-corners-lie.md
Normal file
5
.changeset/wild-corners-lie.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"draupnir": patch
|
||||
---
|
||||
|
||||
Add branch information to status command output.
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -25,8 +25,11 @@ venv/
|
||||
|
||||
/db
|
||||
|
||||
# version file generated from yarn build
|
||||
# version file generated from npm build
|
||||
version.txt
|
||||
# branch file generated from npm build
|
||||
branch.txt
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "tsc --project test/tsconfig.json && npm run build:assets",
|
||||
"build:assets": "cp src/protections/DraupnirNews/news.json dist/protections/DraupnirNews/news.json && npm run describe-version",
|
||||
"build:assets": "cp src/protections/DraupnirNews/news.json dist/protections/DraupnirNews/news.json && npm run describe-version && npm run describe-branch",
|
||||
"describe-version": "(git describe > version.txt.tmp && mv version.txt.tmp version.txt) || true && rm -f version.txt.tmp",
|
||||
"describe-branch": "(git rev-parse --abbrev-ref HEAD > branch.txt.tmp && mv branch.txt.tmp branch.txt) || true && rm -f branch.txt.tmp",
|
||||
"harness-registration": "node dist/appservice/cli.js -r -u \"http://host.docker.internal:9000\" --enable-source-maps",
|
||||
"test:unit": "mocha --require './test/tsnode.cjs' --forbid-only 'test/unit/**/*.{ts,tsx}'",
|
||||
"test:unit:single": "mocha --require test/tsnode.cjs",
|
||||
|
||||
@@ -8,7 +8,12 @@
|
||||
// https://github.com/matrix-org/mjolnir
|
||||
// </text>
|
||||
|
||||
import { DOCUMENTATION_URL, PACKAGE_JSON, SOFTWARE_VERSION } from "../config";
|
||||
import {
|
||||
CURRENT_BRANCH,
|
||||
DOCUMENTATION_URL,
|
||||
PACKAGE_JSON,
|
||||
SOFTWARE_VERSION,
|
||||
} from "../config";
|
||||
import {
|
||||
ActionResult,
|
||||
Ok,
|
||||
@@ -51,6 +56,7 @@ export type StatusInfo = {
|
||||
numberOfProtectedRooms: number;
|
||||
numberOfUniqueMembers: number;
|
||||
version: string;
|
||||
branch: string;
|
||||
repository: string;
|
||||
documentationURL: string;
|
||||
} & DraupnirNotificationRoomsInfo &
|
||||
@@ -135,6 +141,7 @@ export function draupnirStatusInfo(draupnir: Draupnir): StatusInfo {
|
||||
subscribedButPartedLists: watchedListInfo.subscribedButPartedLists,
|
||||
documentationURL: DOCUMENTATION_URL,
|
||||
version: SOFTWARE_VERSION,
|
||||
branch: CURRENT_BRANCH,
|
||||
repository: (PACKAGE_JSON["repository"] as string | undefined) ?? "Unknown",
|
||||
...extractProtectionNotificationRooms(draupnir),
|
||||
};
|
||||
@@ -231,6 +238,9 @@ export function renderStatusInfo(info: StatusInfo): DocumentNode {
|
||||
<b>Version: </b>
|
||||
<code>{info.version}</code>
|
||||
<br />
|
||||
<b>Branch: </b>
|
||||
<code>{info.branch}</code>
|
||||
<br />
|
||||
<b>Repository: </b>
|
||||
<code>{info.repository}</code>
|
||||
<br />
|
||||
|
||||
@@ -471,6 +471,24 @@ export const SOFTWARE_VERSION = (() => {
|
||||
return /^(.*)$/m.exec(versionFile)?.at(0) ?? defaultText;
|
||||
})();
|
||||
|
||||
export const CURRENT_BRANCH = (() => {
|
||||
let branchFile;
|
||||
const defaultText =
|
||||
"A branch name was either not provided when building Draupnir or could not be read.";
|
||||
try {
|
||||
branchFile = fs.readFileSync(
|
||||
path.join(__dirname, "../branch.txt"),
|
||||
"utf-8"
|
||||
);
|
||||
} catch (e) {
|
||||
LogService.error("config", "Could not read Draupnir branch", e);
|
||||
branchFile = defaultText;
|
||||
}
|
||||
// it's important to ignore the newline if the branch is going to be put
|
||||
// into <pre> or <code> where it will create an unnecessary newline.
|
||||
return /^(.*)$/m.exec(branchFile)?.at(0) ?? defaultText;
|
||||
})();
|
||||
|
||||
export const DOCUMENTATION_URL =
|
||||
"https://the-draupnir-project.github.io/draupnir-documentation/";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user