Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91247d31e2 | ||
|
|
f69790c2f9 | ||
|
|
aacee9ddcd |
No files matched your search
@@ -0,0 +1,41 @@
|
||||
# BRAT (Gitea Fork)
|
||||
|
||||
A fork of [obsidian42-brat](https://github.com/TfTHacker/obsidian42-brat) that adds support for **self-hosted Gitea/Forgejo instances** alongside GitHub.
|
||||
|
||||
## What is this?
|
||||
|
||||
BRAT (Beta Reviewers Auto-update Tester) lets you install and auto-update beta Obsidian plugins directly from any git forge that supports releases. This fork extends the original to work with **any Gitea instance** — not just GitHub.
|
||||
|
||||
## Usage
|
||||
|
||||
Open the BRAT command palette and choose **"Add a beta plugin for testing"**, then paste a repository URL:
|
||||
|
||||
| Source | Format | Example |
|
||||
|---|---|---|
|
||||
| **GitHub** | `user/repo` or `https://github.com/user/repo` | `TfTHacker/obsidian42-brat` |
|
||||
| **Gitea** | `https://git.your-instance.com/user/repo` | `https://gitea.mithrilforge.dev/olivier/BindThem` |
|
||||
|
||||
The plugin auto-detects the provider from the URL. Each plugin entry stores its own Gitea instance URL and optional access token.
|
||||
|
||||
## Installation
|
||||
|
||||
Download the latest release assets (`main.js`, `manifest.json`, `styles.css`) and place them in:
|
||||
|
||||
```
|
||||
.obsidian/plugins/obsidian42-brat-gitea/
|
||||
```
|
||||
|
||||
Then enable **BRAT (Gitea Fork)** in Settings → Community Plugins.
|
||||
|
||||
## Features
|
||||
|
||||
- Install plugins from **GitHub** (bare `user/repo` format, backward compatible)
|
||||
- Install plugins from **Gitea / Forgejo** (full URL format)
|
||||
- Per-plugin token management via Obsidian SecretStorage
|
||||
- Frozen version pinning, incompatible plugin overrides
|
||||
- Theme installation and updates
|
||||
- Same UI and commands as the original BRAT
|
||||
|
||||
## Credits
|
||||
|
||||
Original BRAT by [TfTHacker](https://github.com/TfTHacker/obsidian42-brat) and [johannrichard](https://github.com/johannrichard).
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian42-brat-gitea",
|
||||
"name": "BRAT (Gitea Fork)",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.2",
|
||||
"minAppVersion": "1.11.4",
|
||||
"description": "Easily install beta plugins from GitHub AND self-hosted Gitea/Forgejo instances.",
|
||||
"author": "TfTHacker (Gitea fork)",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "obsidian42-brat-gitea",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.2",
|
||||
"description": "BRAT fork with Gitea support — install beta plugins from GitHub or self-hosted Gitea/Forgejo.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
+44
-26
@@ -579,28 +579,26 @@ export default class BetaPlugins {
|
||||
} else {
|
||||
// Update existing plugin
|
||||
const pluginTargetFolderPath = `${this.plugin.app.vault.configDir}/plugins/${primaryManifest.id}/`;
|
||||
let localManifestContents = "";
|
||||
try {
|
||||
localManifestContents = await this.plugin.app.vault.adapter.read(
|
||||
`${pluginTargetFolderPath}manifest.json`,
|
||||
const localManifestPath = `${pluginTargetFolderPath}manifest.json`;
|
||||
const vaultAdapter = this.plugin.app.vault.adapter;
|
||||
if (!(await vaultAdapter.exists(localManifestPath))) {
|
||||
// Plugin folder is empty/missing (deleted by sync, by hand, ...).
|
||||
// Reinstall it. updatePlugin() hard-codes enableAfterInstall=false
|
||||
// for plain updates, which here would leave the plugin installed
|
||||
// but disabled, so use the user's setting instead.
|
||||
return await this.addPlugin(
|
||||
repositoryPath,
|
||||
false,
|
||||
usingBetaManifest,
|
||||
false,
|
||||
specifyVersion,
|
||||
false,
|
||||
this.plugin.settings.enableAfterInstall,
|
||||
secretName,
|
||||
);
|
||||
} catch (e) {
|
||||
const err = e as { errno?: number };
|
||||
if (err.errno === -4058 || err.errno === -2) {
|
||||
await this.addPlugin(
|
||||
repositoryPath,
|
||||
false,
|
||||
usingBetaManifest,
|
||||
false,
|
||||
specifyVersion,
|
||||
false,
|
||||
enableAfterInstall,
|
||||
secretName,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
console.log("BRAT - Local Manifest Load", primaryManifest.id, e);
|
||||
}
|
||||
const localManifestContents =
|
||||
await vaultAdapter.read(localManifestPath);
|
||||
|
||||
if (specifyVersion !== "" && specifyVersion !== "latest") {
|
||||
toastMessage(
|
||||
@@ -641,11 +639,13 @@ export default class BetaPlugins {
|
||||
);
|
||||
// @ts-expect-error
|
||||
await this.plugin.app.plugins.loadManifests();
|
||||
await this.reloadPlugin(primaryManifest.id);
|
||||
const msg = `${primaryManifest.id}\nUpdated: ${localManifestJson.version} → ${primaryManifest.version}. `;
|
||||
const reloaded = await this.reloadPlugin(primaryManifest.id);
|
||||
const msg = reloaded
|
||||
? `${primaryManifest.id}\nUpdated: ${localManifestJson.version} → ${primaryManifest.version}. `
|
||||
: `${primaryManifest.id}\nUpdated files to ${primaryManifest.version}, but failed to re-enable automatically. Enable it manually in Community Plugins.`;
|
||||
await this.plugin.log(msg, true);
|
||||
toastMessage(this.plugin, msg, 30);
|
||||
return true;
|
||||
toastMessage(this.plugin, msg, reloaded ? 30 : 0);
|
||||
return reloaded;
|
||||
}
|
||||
|
||||
if (reportIfNotUpdated) {
|
||||
@@ -669,14 +669,32 @@ export default class BetaPlugins {
|
||||
/**
|
||||
* reloads a plugin
|
||||
*/
|
||||
async reloadPlugin(pluginName: string): Promise<void> {
|
||||
async reloadPlugin(pluginName: string): Promise<boolean> {
|
||||
// @ts-expect-error
|
||||
const { plugins } = this.plugin.app;
|
||||
try {
|
||||
await plugins.disablePlugin(pluginName);
|
||||
await plugins.enablePlugin(pluginName);
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (this.plugin.settings.debuggingMode) console.log("reload plugin", e);
|
||||
const errorMessage = e instanceof Error ? e.message : String(e);
|
||||
console.error(`BRAT: Failed to reload plugin ${pluginName}`, e);
|
||||
await this.plugin.log(
|
||||
`Failed to reload ${pluginName} after update: ${errorMessage}`,
|
||||
true,
|
||||
);
|
||||
try {
|
||||
await plugins.enablePluginAndSave(pluginName);
|
||||
return true;
|
||||
} catch (e2) {
|
||||
const fallbackMessage = e2 instanceof Error ? e2.message : String(e2);
|
||||
console.error(`BRAT: Fallback re-enable failed for ${pluginName}`, e2);
|
||||
await this.plugin.log(
|
||||
`Fallback re-enable also failed for ${pluginName}: ${fallbackMessage}`,
|
||||
true,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user