github
github ¶
GitHub integration for daily journal automation.
add_checkmarks_to_closed_issues ¶
Update existing GitHub issue links in markdown content to add checkmarks for closed issues.
Searches for formatted GitHub issue links without checkmarks and queries GitHub to determine their current state, adding ✅ prefix to closed issues.
:param content: Markdown content containing GitHub issue links :param repo: Repository name in "owner/repo" format :param dry_run: If True, only print what would be changed without modifying content :return: Updated markdown content with checkmarks added to closed issues
Source code in packages/journal-lib/src/journal_lib/github.py
deduplicate_github_items ¶
Remove duplicate GitHub items based on URL and sort by repository and number.
:param items: List of GitHub items (issues or PRs) :return: Deduplicated and sorted list of items
Source code in packages/journal-lib/src/journal_lib/github.py
detect_repo_from_content ¶
Extract repository name from GitHub links found in markdown content.
Searches for existing GitHub issue or PR links to determine which repository is being referenced. Falls back to configured default repo if no links found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
Markdown content to search for GitHub links |
required |
Returns:
Type | Description |
---|---|
str
|
Repository name in format "owner/repo" |
Source code in packages/journal-lib/src/journal_lib/github.py
escape_markdown ¶
Escape special markdown characters to prevent injection attacks.
:param text: Text that may contain markdown special characters :return: Text with markdown special characters escaped
Source code in packages/journal-lib/src/journal_lib/github.py
extract_repo_from_url ¶
Extract repository name from GitHub URL with validation.
:param url: GitHub URL (issue or PR) :return: Repository name in "owner/repo" format
Source code in packages/journal-lib/src/journal_lib/github.py
fetch_issues_closed ¶
Retrieve GitHub issues closed in specified period that were created by or assigned to user.
Searches for all closed issues in the period, then filters to only include those authored by or assigned to the authenticated user.
:param period: Time period to search ("today", "this-week", or YYYY-MM-DD) :return: List of issue dictionaries with number, title, url, state, assignees, and author
Source code in packages/journal-lib/src/journal_lib/github.py
fetch_issues_created ¶
Retrieve GitHub issues created by the authenticated user in specified period.
Searches across multiple organizations (digitalgedacht, nexiles) and personal repositories for issues authored by the user.
:param period: Time period to search ("today", "this-week", or YYYY-MM-DD) :return: List of issue dictionaries with number, title, url, and state
Source code in packages/journal-lib/src/journal_lib/github.py
fetch_issues_worked_on ¶
Retrieve GitHub issues the user was involved with in specified period.
Uses GitHub's "involves:{config.github_user}" search to find issues where the user commented, was assigned, mentioned, or otherwise participated.
:param period: Time period to search ("today", "this-week", or YYYY-MM-DD) :return: List of issue dictionaries with number, title, url, and state
Source code in packages/journal-lib/src/journal_lib/github.py
fetch_prs_created ¶
Retrieve GitHub pull requests created by or assigned to the user in specified period.
Searches across multiple organizations for PRs where the user is either the author or assignee.
:param period: Time period to search ("today", "this-week", or YYYY-MM-DD) :return: List of PR dictionaries with number, title, url, state, and timestamps
Source code in packages/journal-lib/src/journal_lib/github.py
fetch_prs_merged ¶
Retrieve GitHub pull requests merged in specified period that were authored by or assigned to user.
Searches across multiple organizations for merged PRs where the user is either the author or assignee.
:param period: Time period to search ("today", "this-week", or YYYY-MM-DD) :return: List of PR dictionaries with number, title, url, state, and timestamps
Source code in packages/journal-lib/src/journal_lib/github.py
format_all_github_refs ¶
Comprehensively format all GitHub references in markdown content.
Performs two operations: 1. Adds checkmarks to existing formatted issue links that are closed 2. Converts unformatted references to proper markdown links
:param content: Markdown content to process :param repo: Repository name in "owner/repo" format, auto-detected if None :param dry_run: If True, only print what would be changed without modifying content :return: Updated markdown content with all GitHub references properly formatted
Source code in packages/journal-lib/src/journal_lib/github.py
format_issue_ref ¶
Format GitHub issue as markdown link with repository prefix and visual indicator for closed state.
Creates a markdown link in format: [owner/repo#123](url) -- ✅ Title
for closed
issues, or [owner/repo#123](url) -- Title
for open issues.
:param issue: Issue dictionary containing number, title, url, and state :return: Formatted markdown link string with repository prefix
Source code in packages/journal-lib/src/journal_lib/github.py
format_pr_ref ¶
Format GitHub pull request as markdown link with repository prefix, creation and merge timestamps.
Creates a markdown link with repository prefix and timestamps showing when the PR was opened and optionally when it was merged.
:param pr: PR dictionary containing number, title, url, createdAt, and optionally mergedAt :return: Formatted markdown link string with repository prefix and timestamps
Source code in packages/journal-lib/src/journal_lib/github.py
format_unformatted_github_refs ¶
Convert plain GitHub references to formatted markdown links with titles.
Finds unformatted references like "Issue #123" or "PR #456" and converts them to proper markdown links with titles fetched from GitHub API.
:param content: Markdown content containing unformatted GitHub references :param repo: Repository name in "owner/repo" format :param dry_run: If True, only print what would be changed without modifying content :return: Updated markdown content with formatted GitHub links
Source code in packages/journal-lib/src/journal_lib/github.py
get_date_range ¶
Convert period specification to date string for GitHub search queries.
Accepts specific dates in YYYY-MM-DD format or period keywords. Currently only "today" is fully implemented, other periods default to today.
:param period: Date period specification ("today", "this-week", "YYYY-MM-DD", etc.) :return: Date string in YYYY-MM-DD format
Source code in packages/journal-lib/src/journal_lib/github.py
get_default_daily_note ¶
Get file system path to daily note file for specified date.
:param date: Date in YYYY-MM-DD format, defaults to today if None :return: Path object pointing to daily note file
Source code in packages/journal-lib/src/journal_lib/github.py
run_gh_command ¶
Run GitHub CLI command and return JSON result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmd
|
list[str]
|
Command arguments to pass to the gh CLI |
required |
single
|
bool
|
If True, return single dict; if False, return list |
False
|
Returns:
Type | Description |
---|---|
list[dict[str, Any]] | dict[str, Any]
|
JSON response parsed as list or dictionary, empty result on error |
Source code in packages/journal-lib/src/journal_lib/github.py
update_daily_review_section ¶
Replace or append Daily Review section in markdown content with GitHub activity data.
Creates a comprehensive daily review section showing issues created, PRs created, issues closed, issues worked on, and PRs merged. Deduplicates items by URL and sorts them by repository for cleaner display.
:param content: Existing markdown content :param github_data: Dictionary containing lists of GitHub items by category :return: Updated markdown content with Daily Review section
Source code in packages/journal-lib/src/journal_lib/github.py
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
|