Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
45 changes: 27 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,74 @@ An Obsidian plugin that integrates with GitHub to track issues and pull requests

>The configurations are heavily inspired by https://github.com/schaier-io, including some specific settings. However, I had already started working on my prototype before I discovered the plugin, and had initially even given it a similar name.

## ✨ Features
# Documentation
Check out the [documentation](https://github.com/LonoxX/obsidian-github-issues/wiki) for detailed information on setup, configuration, and usage.

### 🔄 Issue & Pull Request Tracking
## Features

### Issue & Pull Request Tracking
- Track issues and pull requests from multiple GitHub repositories
- Automatically sync GitHub data on startup (configurable)
- Background sync at configurable intervals
- Filter by labels, assignees, and reviewers
- Include or exclude closed issues/PRs
- Automatic cleanup of old closed items

### 📊 GitHub Projects v2 Integration
### GitHub Projects v2 Integration
- Track GitHub Projects across repositories
- Kanban board view for project visualization
- Custom field support (status, priority, iteration)
- Project-specific filtering and organization

### 📝 Markdown Notes
### Sub-Issues Support
- Track GitHub sub-issues (parent/child relationships)
- Display sub-issues list with status indicators
- Navigate between parent and child issues
- Progress tracking with completion percentage

### Markdown Notes
- Create markdown notes for each issue or PR
- Customizable filename templates with variables
- Custom content templates
- YAML frontmatter with metadata
- Preserve user content with persist blocks
- Include comments in notes

## 🚀 Installation
## Installation

### Via Community Plugins (Recommended)

### Via Obsidian Community Plugins
1. Open Obsidian settings
1. Open Obsidian Settings
2. Navigate to **Community Plugins**
3. Click **Browse** and search for "GitHub Issues"
4. Click **Install** and then **Enable**

### Manual Installation

1. Download the latest release from the [GitHub Releases page](https://github.com/LonoxX/obsidian-github-issues/releases).
2. Extract the contents into your Obsidian plugins folder:
`<vault>/.obsidian/plugins/github-issues/`
3. Enable the plugin in Obsidian under **Community Plugins**
4. Reload or restart Obsidian
1. Download the latest release from [GitHub Releases](https://github.com/LonoxX/obsidian-github-issues/releases)
2. Extract to `<vault>/.obsidian/plugins/github-issues/`
3. Enable the plugin in **Community Plugins**
4. Reload Obsidian

## ⚙️ Configuration

## Configuration

1. Create a new GitHub token with the `repo` and `read:org` permissions
→ [GitHub Settings > Developer Settings > Personal access tokens](https://github.com/settings/tokens)
2. Configure the plugin in Obsidian settings:
- Paste your GitHub token in the **GitHub Token** field
- Adjust additional settings as needed

## 📦 Adding Repositories
## Adding Repositories

1. Open the plugin settings in Obsidian
2. Add repositories by entering the full GitHub repository path (e.g., `lonoxx/obsidian-github-issues`),
or use the repository browser to select one or multiple repositories
3. Click **Add Repository** or **Add Selected Repositories**
4. The plugin will automatically fetch issues from the configured repositories

### ⭐ This repository if you like this project!

## Support

## 📄 License
If you find this plugin useful and would like to support its development, you can star the repository or support me on Ko-fi or [GitHub Sponsors](https://github.com/sponsors/LonoxX):

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/LonoxX)
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"author": "LonoxX",
"license": "MIT",
"devDependencies": {
"@types/node": "^25.0.3",
"@typescript-eslint/eslint-plugin": "^8.52.0",
"@typescript-eslint/parser": "^8.52.0",
"@types/node": "^25.0.8",
"@typescript-eslint/eslint-plugin": "^8.53.0",
"@typescript-eslint/parser": "^8.53.0",
"builtin-modules": "^5.0.0",
"esbuild": "^0.27.2",
"eslint": "^9.39.2",
"obsidian": "latest",
"obsidian": "^1.11.4",
"tslib": "^2.8.1",
"typescript": "^5.9.3"
},
Expand Down
6 changes: 5 additions & 1 deletion src/content-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export class ContentGenerator {
comments: any[],
settings: GitHubTrackerSettings,
projectData?: ProjectData[],
subIssues?: any[],
parentIssue?: any,
): Promise<string> {
// Determine whether to escape hash tags (repo setting takes precedence if ignoreGlobalSettings is true)
const shouldEscapeHashTags = repo.ignoreGlobalSettings ? repo.escapeHashTags : settings.escapeHashTags;
Expand All @@ -37,7 +39,9 @@ export class ContentGenerator {
settings.dateFormat,
settings.escapeMode,
shouldEscapeHashTags,
projectData
projectData,
subIssues,
parentIssue
);
return processContentTemplate(templateContent, templateData, settings.dateFormat);
}
Expand Down
43 changes: 38 additions & 5 deletions src/file-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class FileManager {
private app: App,
private settings: GitHubTrackerSettings,
private noticeManager: NoticeManager,
gitHubClient: GitHubClient,
private gitHubClient: GitHubClient,
) {
this.issueFileManager = new IssueFileManager(app, settings, noticeManager, gitHubClient);
this.prFileManager = new PullRequestFileManager(app, settings, noticeManager, gitHubClient);
Expand Down Expand Up @@ -159,6 +159,29 @@ export class FileManager {
const repository = this.extractRepositoryFromUrl(content.url) || `${project.owner}/unknown`;
const projectData = this.convertFieldValuesToProjectData(project, status, item.fieldValues?.nodes || []);

// Fetch sub-issues and parent issue for template support (only if enabled for project)
let subIssues: any[] = [];
let parentIssue: any = null;

if (isIssue && project.includeSubIssues) {
const [owner, repoName] = repository.split("/");
if (owner && repoName) {
subIssues = await this.gitHubClient.fetchSubIssues(owner, repoName, content.number);
parentIssue = await this.gitHubClient.fetchParentIssue(owner, repoName, content.number);

// Enrich sub-issues with vault paths if they exist
const noteTemplate = project.issueNoteTemplate || "Issue - {number} - {title}";
subIssues = await this.fileHelpers.enrichSubIssuesWithVaultPaths(
Comment thread
LonoxX marked this conversation as resolved.
subIssues,
folderPath,
noteTemplate,
repository,
this.settings.dateFormat,
this.settings.escapeMode
);
}
}

const templateData = isIssue
? createIssueTemplateData(
this.convertToIssueFormat(content),
Expand All @@ -167,7 +190,9 @@ export class FileManager {
this.settings.dateFormat,
this.settings.escapeMode,
this.settings.escapeHashTags,
[projectData]
[projectData],
subIssues,
parentIssue
)
: createPullRequestTemplateData(
this.convertToPullRequestFormat(content),
Expand All @@ -193,7 +218,9 @@ export class FileManager {
project,
status,
isIssue,
item.fieldValues?.nodes || []
item.fieldValues?.nodes || [],
subIssues,
parentIssue
);

if (existingFile && existingFile instanceof TFile) {
Expand Down Expand Up @@ -226,6 +253,8 @@ export class FileManager {
status: string,
isIssue: boolean,
fieldValues: any[],
subIssues?: any[],
parentIssue?: any,
): Promise<string> {
const shouldEscapeHashTags = this.settings.escapeHashTags;

Expand Down Expand Up @@ -255,7 +284,9 @@ export class FileManager {
this.settings.dateFormat,
this.settings.escapeMode,
shouldEscapeHashTags,
[projectData]
[projectData],
subIssues,
parentIssue
)
: createPullRequestTemplateData(
this.convertToPullRequestFormat(content),
Expand All @@ -272,7 +303,7 @@ export class FileManager {
}

// Fallback to default format
return this.generateDefaultProjectItemContent(content, project, status, isIssue, fieldValues);
return this.generateDefaultProjectItemContent(content, project, status, isIssue, fieldValues, subIssues, parentIssue);
}

/**
Expand All @@ -284,6 +315,8 @@ export class FileManager {
status: string,
isIssue: boolean,
fieldValues: any[],
subIssues?: any[],
parentIssue?: any,
): string {
const shouldEscapeHashTags = this.settings.escapeHashTags;
const dateFormat = this.settings.dateFormat;
Expand Down
97 changes: 95 additions & 2 deletions src/github-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,22 @@ import {
export class GitHubClient {
private octokit: Octokit | null = null;
private currentUser: string = "";
private tokenGetter: () => string;

constructor(
private settings: GitHubTrackerSettings,
private noticeManager: NoticeManager,
tokenGetter: () => string,
) {
this.tokenGetter = tokenGetter;
this.initializeClient();
}

/**
* Initialize GitHub client with the current token
*/
public initializeClient(token?: string): void {
const authToken = token || this.settings.githubToken;
public initializeClient(): void {
const authToken = this.tokenGetter();

if (!authToken) {
this.noticeManager.error(
Expand Down Expand Up @@ -1038,6 +1041,96 @@ export class GitHubClient {
}
}

/**
* Fetch sub-issues for an issue
* Uses the GitHub Sub-Issues API: GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues
*/
public async fetchSubIssues(
owner: string,
repo: string,
issueNumber: number,
): Promise<any[]> {
if (!this.octokit) {
return [];
}

try {
let allSubIssues: any[] = [];
let page = 1;
let hasMorePages = true;

while (hasMorePages) {
const response = await this.octokit.request(
Comment thread
LonoxX marked this conversation as resolved.
Comment thread
LonoxX marked this conversation as resolved.
Comment thread
LonoxX marked this conversation as resolved.
Comment thread
LonoxX marked this conversation as resolved.
'GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues',
{
owner,
repo,
issue_number: issueNumber,
per_page: 100,
page,
}
);

allSubIssues = [...allSubIssues, ...response.data];
hasMorePages = response.data.length === 100;
page++;
}

this.noticeManager.debug(
`Fetched ${allSubIssues.length} sub-issues for issue #${issueNumber}`,
);
return allSubIssues;
} catch (error: any) {
// 404 means no sub-issues or feature not available
if (error.status === 404) {
return [];
}
this.noticeManager.debug(
`Error fetching sub-issues for issue #${issueNumber}: ${error.message}`,
);
return [];
}
}

/**
* Fetch parent issue for a sub-issue
* Uses the GitHub Sub-Issues API: GET /repos/{owner}/{repo}/issues/{issue_number}/parent
*/
public async fetchParentIssue(
owner: string,
repo: string,
issueNumber: number,
): Promise<any | null> {
if (!this.octokit) {
return null;
}

try {
const response = await this.octokit.request(
'GET /repos/{owner}/{repo}/issues/{issue_number}/parent',
{
owner,
repo,
issue_number: issueNumber,
}
);

this.noticeManager.debug(
`Found parent issue #${response.data.number} for issue #${issueNumber}`,
);
return response.data;
} catch (error: any) {
// 404 means no parent issue
if (error.status === 404) {
return null;
}
this.noticeManager.debug(
`Error fetching parent issue for #${issueNumber}: ${error.message}`,
);
return null;
}
}

public dispose(): void {
this.octokit = null;
this.currentUser = "";
Expand Down
34 changes: 33 additions & 1 deletion src/issue-file-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,36 @@ export class IssueFileManager {
);
}

let content = await this.contentGenerator.createIssueContent(issue, repo, comments, this.settings);
// Fetch sub-issues and parent issue for template support (only if enabled)
let subIssues: any[] = [];
let parentIssue: any = null;

if (repo.includeSubIssues) {
subIssues = await this.gitHubClient.fetchSubIssues(owner, repoName, issue.number);
parentIssue = await this.gitHubClient.fetchParentIssue(owner, repoName, issue.number);

// Enrich sub-issues with vault paths if they exist
const issueFolder = this.folderPathManager.getIssueFolderPath(repo, owner, repoName);
const noteTemplate = repo.issueNoteTemplate || "Issue - {number}";
subIssues = await this.fileHelpers.enrichSubIssuesWithVaultPaths(
Comment thread
LonoxX marked this conversation as resolved.
subIssues,
issueFolder,
noteTemplate,
repo.repository,
this.settings.dateFormat,
this.settings.escapeMode
);
}

let content = await this.contentGenerator.createIssueContent(
Comment thread
LonoxX marked this conversation as resolved.
issue,
repo,
comments,
this.settings,
undefined, // projectData
subIssues,
parentIssue
);

if (file) {
if (file instanceof TFile) {
Expand Down Expand Up @@ -146,6 +175,9 @@ export class IssueFileManager {
repo,
comments,
this.settings,
undefined, // projectData
subIssues,
parentIssue
);

// Merge persist blocks back into new content
Expand Down
Loading