Skip to content

Commit 4e92345

Browse files
committed
feat: Global Settings should override pre-repository settings
1 parent 856ef89 commit 4e92345

11 files changed

Lines changed: 824 additions & 198 deletions

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ The configurations are heavily inspired by https://github.com/schaier-io, includ
1414
## 🚀 Installation
1515

1616
### Via Obsidian Community Plugins
17-
18-
> **Note:** This plugin is not yet available in the Community Plugins list.
19-
2017
1. Open Obsidian settings
2118
2. Navigate to **Community Plugins**
2219
3. Click **Browse** and search for "GitHub Issues"

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "github-issues",
33
"name": "Github Issues",
4-
"version": "1.0.4",
4+
"version": "1.2.3",
55
"minAppVersion": "0.15.0",
66
"description": "Track Github Issues and pull requests directly in your vault",
77
"author": "LonoxX",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-issues",
3-
"version": "1.0.4",
3+
"version": "1.2.3",
44
"description": "Track GitHub issues and pull requests in Obsidian",
55
"main": "main.js",
66
"scripts": {

src/file-manager.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
processContentTemplate,
1414
extractNumberFromFilename
1515
} from "./util/templateUtils";
16+
import { getEffectiveRepoSettings } from "./util/settingsUtils";
1617

1718
export class FileManager {
1819
constructor(
@@ -50,12 +51,15 @@ export class FileManager {
5051
allIssuesIncludingRecentlyClosed: any[],
5152
_currentIssueNumbers: Set<string>,
5253
): Promise<void> {
53-
const [owner, repoName] = repo.repository.split("/");
54+
// Apply global defaults to repository settings
55+
const effectiveRepo = getEffectiveRepoSettings(repo, this.settings.globalDefaults);
56+
57+
const [owner, repoName] = effectiveRepo.repository.split("/");
5458
if (!owner || !repoName) return;
5559
const repoCleaned = repoName.replace(/\//g, "-");
5660
const ownerCleaned = owner.replace(/\//g, "-");
5761
await this.cleanupDeletedIssues(
58-
repo,
62+
effectiveRepo,
5963
ownerCleaned,
6064
repoCleaned,
6165
allIssuesIncludingRecentlyClosed,
@@ -64,7 +68,7 @@ export class FileManager {
6468
// Create or update issue files for open issues
6569
for (const issue of openIssues) {
6670
await this.createOrUpdateIssueFile(
67-
repo,
71+
effectiveRepo,
6872
ownerCleaned,
6973
repoCleaned,
7074
issue,
@@ -81,22 +85,25 @@ export class FileManager {
8185
allPullRequestsIncludingRecentlyClosed: any[],
8286
_currentPRNumbers: Set<string>,
8387
): Promise<void> {
84-
const [owner, repoName] = repo.repository.split("/");
88+
// Apply global defaults to repository settings
89+
const effectiveRepo = getEffectiveRepoSettings(repo, this.settings.globalDefaults);
90+
91+
const [owner, repoName] = effectiveRepo.repository.split("/");
8592
if (!owner || !repoName) return;
8693

8794
const repoCleaned = repoName.replace(/\//g, "-");
8895
const ownerCleaned = owner.replace(/\//g, "-");
8996

9097
await this.cleanupDeletedPullRequests(
91-
repo,
98+
effectiveRepo,
9299
ownerCleaned,
93100
repoCleaned,
94101
allPullRequestsIncludingRecentlyClosed,
95102
);
96103

97104
for (const pr of openPullRequests) {
98105
await this.createOrUpdatePullRequestFile(
99-
repo,
106+
effectiveRepo,
100107
ownerCleaned,
101108
repoCleaned,
102109
pr,
@@ -565,6 +572,12 @@ export class FileManager {
565572
}
566573

567574
private async ensureFolderExists(path: string): Promise<void> {
575+
// Guard against undefined or empty paths
576+
if (!path || path.trim() === "") {
577+
this.noticeManager.error("Cannot create folder: path is empty or undefined");
578+
return;
579+
}
580+
568581
const folder = this.app.vault.getAbstractFileByPath(path);
569582
if (!folder) {
570583
try {

src/main.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,19 @@ export default class GitHubTrackerPlugin extends Plugin {
257257
const loadedData = await this.loadData();
258258
this.settings = Object.assign({}, DEFAULT_SETTINGS, loadedData);
259259

260+
// Ensure globalDefaults exists (migration for existing users)
261+
if (!this.settings.globalDefaults) {
262+
this.settings.globalDefaults = Object.assign({}, DEFAULT_SETTINGS.globalDefaults);
263+
}
264+
260265
// Migrate existing repositories to include new custom folder properties
266+
// Defaults first, then override with saved values
261267
this.settings.repositories = this.settings.repositories.map(repo => {
262-
return Object.assign({}, DEFAULT_REPOSITORY_TRACKING, repo);
268+
const merged = Object.assign({}, DEFAULT_REPOSITORY_TRACKING, repo);
269+
// Ensure critical fields are never undefined
270+
if (!merged.issueFolder) merged.issueFolder = DEFAULT_REPOSITORY_TRACKING.issueFolder;
271+
if (!merged.pullRequestFolder) merged.pullRequestFolder = DEFAULT_REPOSITORY_TRACKING.pullRequestFolder;
272+
return merged;
263273
});
264274
}
265275

0 commit comments

Comments
 (0)