Payload
{
"action": "resolved",
"pull_request": {
"url": "https://api.github.com/repos/darkmatter/nixmac/pulls/274",
"id": 3785478618,
"node_id": "PR_kwDOSB6EzM7hodHa",
"html_url": "https://github.com/darkmatter/nixmac/pull/274",
"diff_url": "https://github.com/darkmatter/nixmac/pull/274.diff",
"patch_url": "https://github.com/darkmatter/nixmac/pull/274.patch",
"issue_url": "https://api.github.com/repos/darkmatter/nixmac/issues/274",
"number": 274,
"state": "open",
"locked": false,
"title": "refactor: migrate git init, status, and basic diff to git2, including using objects more than strings/parsing.",
"user": {
"login": "scottmcmaster",
"id": 3137688,
"node_id": "MDQ6VXNlcjMxMzc2ODg=",
"avatar_url": "https://avatars.githubusercontent.com/u/3137688?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/scottmcmaster",
"html_url": "https://github.com/scottmcmaster",
"followers_url": "https://api.github.com/users/scottmcmaster/followers",
"following_url": "https://api.github.com/users/scottmcmaster/following{/other_user}",
"gists_url": "https://api.github.com/users/scottmcmaster/gists{/gist_id}",
"starred_url": "https://api.github.com/users/scottmcmaster/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/scottmcmaster/subscriptions",
"organizations_url": "https://api.github.com/users/scottmcmaster/orgs",
"repos_url": "https://api.github.com/users/scottmcmaster/repos",
"events_url": "https://api.github.com/users/scottmcmaster/events{/privacy}",
"received_events_url": "https://api.github.com/users/scottmcmaster/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"body": "## Summary\r\n\r\nMove the next most impactful set of git functionality from CLI subprocesses to libgit:\r\n\r\n- Moved repository initialization and validation functions to a new init.rs module.\r\n- Updated status function to utilize structured diff handling via git2.\r\n- Enhanced commit_diff to return structured file diffs via git2 for better change representation and perf.\r\n- Removed redundant and obsolete functions and tests related to previous diff handling.\r\n- Improved change type mapping and added tests for new functionality.\r\n- Updated various modules to reflect changes in the git query structure.\r\n- Try to maintain public API compat as much as possible to (hopefully) avoid breaking a lot of complex stuff in the summarization pipeline.\r\n\r\n## Test Plan\r\n\r\nUpdated and added unit tests, ran through several manual tests and used some temp logging of the FileDiff/Changes structures.\r\n\r\n## Docs\r\n\r\n- [ ] Docs updated\r\n- [x] No docs update needed\r\n\r\n<!-- codesmith:footer -->\r\n---\r\n<a href=\"https://app.blacksmith.sh/darkmatter/codesmith/nixmac/pr/274\"><picture><source media=\"(prefers-color-scheme: dark)\" srcset=\"https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg\"><source media=\"(prefers-color-scheme: light)\" srcset=\"https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v2.svg\"><img alt=\"View with Codesmith\" src=\"https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg\"></picture></a> <a href=\"https://backend.blacksmith.sh/track/enable-autofix?expires=1782966307&installation_id=137091173&pr_number=274&repository=darkmatter%2Fnixmac&return_to=https%3A%2F%2Fgithub.com%2Fdarkmatter%2Fnixmac%2Fpull%2F274&signature=248bcf8ca77412639454f19745fb03d923c1728e354599bd9048ed7fa04f9f85\"><picture><source media=\"(prefers-color-scheme: dark)\" srcset=\"https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg\"><source media=\"(prefers-color-scheme: light)\" srcset=\"https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg\"><img alt=\"Autofix with Codesmith\" src=\"https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg\"></picture></a>\r\n<sup>Need help on this PR? Tag <code>@codesmith</code> with what you need. Autofix is disabled.</sup>\r\n\r\n<!-- codesmith:autofix:disabled -->\r\n<!-- /codesmith:footer -->",
"created_at": "2026-06-02T04:25:04Z",
"updated_at": "2026-06-02T05:33:51Z",
"closed_at": null,
"merged_at": null,
"merge_commit_sha": "d1777b522f7e635d0d967ccdb588f7b79df35586",
"assignees": [],
"requested_reviewers": [
{
"login": "czxtm",
"id": 1325802,
"node_id": "MDQ6VXNlcjEzMjU4MDI=",
"avatar_url": "https://avatars.githubusercontent.com/u/1325802?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/czxtm",
"html_url": "https://github.com/czxtm",
"followers_url": "https://api.github.com/users/czxtm/followers",
"following_url": "https://api.github.com/users/czxtm/following{/other_user}",
"gists_url": "https://api.github.com/users/czxtm/gists{/gist_id}",
"starred_url": "https://api.github.com/users/czxtm/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/czxtm/subscriptions",
"organizations_url": "https://api.github.com/users/czxtm/orgs",
"repos_url": "https://api.github.com/users/czxtm/repos",
"events_url": "https://api.github.com/users/czxtm/events{/privacy}",
"received_events_url": "https://api.github.com/users/czxtm/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
}
],
"requested_teams": [],
"labels": [],
"milestone": null,
"draft": false,
"commits_url": "https://api.github.com/repos/darkmatter/nixmac/pulls/274/commits",
"review_comments_url": "https://api.github.com/repos/darkmatter/nixmac/pulls/274/comments",
"review_comment_url": "https://api.github.com/repos/darkmatter/nixmac/pulls/comments{/number}",
"comments_url": "https://api.github.com/repos/darkmatter/nixmac/issues/274/comments",
"statuses_url": "https://api.github.com/repos/darkmatter/nixmac/statuses/596b117a6d03617358d0a89fe8c9c49eba334bc0",
"head": {
"label": "darkmatter:06-01-scott_more-git2",
"ref": "06-01-scott_more-git2",
"sha": "596b117a6d03617358d0a89fe8c9c49eba334bc0",
"user": {
"login": "darkmatter",
"id": 17834193,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE3ODM0MTkz",
"avatar_url": "https://avatars.githubusercontent.com/u/17834193?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/darkmatter",
"html_url": "https://github.com/darkmatter",
"followers_url": "https://api.github.com/users/darkmatter/followers",
"following_url": "https://api.github.com/users/darkmatter/following{/other_user}",
"gists_url": "https://api.github.com/users/darkmatter/gists{/gist_id}",
"starred_url": "https://api.github.com/users/darkmatter/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/darkmatter/subscriptions",
"organizations_url": "https://api.github.com/users/darkmatter/orgs",
"repos_url": "https://api.github.com/users/darkmatter/repos",
"events_url": "https://api.github.com/users/darkmatter/events{/privacy}",
"received_events_url": "https://api.github.com/users/darkmatter/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"repo": {
"id": 1209959628,
"node_id": "R_kgDOSB6EzA",
"name": "nixmac",
"full_name": "darkmatter/nixmac",
"private": false,
"owner": {
"login": "darkmatter",
"id": 17834193,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE3ODM0MTkz",
"avatar_url": "https://avatars.githubusercontent.com/u/17834193?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/darkmatter",
"html_url": "https://github.com/darkmatter",
"followers_url": "https://api.github.com/users/darkmatter/followers",
"following_url": "https://api.github.com/users/darkmatter/following{/other_user}",
"gists_url": "https://api.github.com/users/darkmatter/gists{/gist_id}",
"starred_url": "https://api.github.com/users/darkmatter/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/darkmatter/subscriptions",
"organizations_url": "https://api.github.com/users/darkmatter/orgs",
"repos_url": "https://api.github.com/users/darkmatter/repos",
"events_url": "https://api.github.com/users/darkmatter/events{/privacy}",
"received_events_url": "https://api.github.com/users/darkmatter/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"html_url": "https://github.com/darkmatter/nixmac",
"description": "Home manager and nix-darwin that understands plain English",
"fork": false,
"url": "https://api.github.com/repos/darkmatter/nixmac",
"forks_url": "https://api.github.com/repos/darkmatter/nixmac/forks",
"keys_url": "https://api.github.com/repos/darkmatter/nixmac/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/darkmatter/nixmac/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/darkmatter/nixmac/teams",
"hooks_url": "https://api.github.com/repos/darkmatter/nixmac/hooks",
"issue_events_url": "https://api.github.com/repos/darkmatter/nixmac/issues/events{/number}",
"events_url": "https://api.github.com/repos/darkmatter/nixmac/events",
"assignees_url": "https://api.github.com/repos/darkmatter/nixmac/assignees{/user}",
"branches_url": "https://api.github.com/repos/darkmatter/nixmac/branches{/branch}",
"tags_url": "https://api.github.com/repos/darkmatter/nixmac/tags",
"blobs_url": "https://api.github.com/repos/darkmatter/nixmac/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/darkmatter/nixmac/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/darkmatter/nixmac/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/darkmatter/nixmac/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/darkmatter/nixmac/statuses/{sha}",
"languages_url": "https://api.github.com/repos/darkmatter/nixmac/languages",
"stargazers_url": "https://api.github.com/repos/darkmatter/nixmac/stargazers",
"contributors_url": "https://api.github.com/repos/darkmatter/nixmac/contributors",
"subscribers_url": "https://api.github.com/repos/darkmatter/nixmac/subscribers",
"subscription_url": "https://api.github.com/repos/darkmatter/nixmac/subscription",
"commits_url": "https://api.github.com/repos/darkmatter/nixmac/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/darkmatter/nixmac/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/darkmatter/nixmac/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/darkmatter/nixmac/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/darkmatter/nixmac/contents/{+path}",
"compare_url": "https://api.github.com/repos/darkmatter/nixmac/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/darkmatter/nixmac/merges",
"archive_url": "https://api.github.com/repos/darkmatter/nixmac/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/darkmatter/nixmac/downloads",
"issues_url": "https://api.github.com/repos/darkmatter/nixmac/issues{/number}",
"pulls_url": "https://api.github.com/repos/darkmatter/nixmac/pulls{/number}",
"milestones_url": "https://api.github.com/repos/darkmatter/nixmac/milestones{/number}",
"notifications_url": "https://api.github.com/repos/darkmatter/nixmac/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/darkmatter/nixmac/labels{/name}",
"releases_url": "https://api.github.com/repos/darkmatter/nixmac/releases{/id}",
"deployments_url": "https://api.github.com/repos/darkmatter/nixmac/deployments",
"created_at": "2026-04-14T00:37:13Z",
"updated_at": "2026-06-01T06:15:50Z",
"pushed_at": "2026-06-02T04:25:03Z",
"git_url": "git://github.com/darkmatter/nixmac.git",
"ssh_url": "git@github.com:darkmatter/nixmac.git",
"clone_url": "https://github.com/darkmatter/nixmac.git",
"svn_url": "https://github.com/darkmatter/nixmac",
"homepage": "https://nixmac.com",
"size": 679049,
"stargazers_count": 5,
"watchers_count": 5,
"language": "Rust",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"has_discussions": false,
"forks_count": 1,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 90,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"has_pull_requests": true,
"pull_request_creation_policy": "all",
"topics": [
"home-manager",
"nix",
"nix-darwin",
"nix-flake",
"opencode"
],
"visibility": "public",
"forks": 1,
"open_issues": 90,
"watchers": 5,
"default_branch": "develop"
}
},
"base": {
"label": "darkmatter:develop",
"ref": "develop",
"sha": "69a5f878cf46a847f650e5e3716669aca25fee0d",
"user": {
"login": "darkmatter",
"id": 17834193,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE3ODM0MTkz",
"avatar_url": "https://avatars.githubusercontent.com/u/17834193?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/darkmatter",
"html_url": "https://github.com/darkmatter",
"followers_url": "https://api.github.com/users/darkmatter/followers",
"following_url": "https://api.github.com/users/darkmatter/following{/other_user}",
"gists_url": "https://api.github.com/users/darkmatter/gists{/gist_id}",
"starred_url": "https://api.github.com/users/darkmatter/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/darkmatter/subscriptions",
"organizations_url": "https://api.github.com/users/darkmatter/orgs",
"repos_url": "https://api.github.com/users/darkmatter/repos",
"events_url": "https://api.github.com/users/darkmatter/events{/privacy}",
"received_events_url": "https://api.github.com/users/darkmatter/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"repo": {
"id": 1209959628,
"node_id": "R_kgDOSB6EzA",
"name": "nixmac",
"full_name": "darkmatter/nixmac",
"private": false,
"owner": {
"login": "darkmatter",
"id": 17834193,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE3ODM0MTkz",
"avatar_url": "https://avatars.githubusercontent.com/u/17834193?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/darkmatter",
"html_url": "https://github.com/darkmatter",
"followers_url": "https://api.github.com/users/darkmatter/followers",
"following_url": "https://api.github.com/users/darkmatter/following{/other_user}",
"gists_url": "https://api.github.com/users/darkmatter/gists{/gist_id}",
"starred_url": "https://api.github.com/users/darkmatter/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/darkmatter/subscriptions",
"organizations_url": "https://api.github.com/users/darkmatter/orgs",
"repos_url": "https://api.github.com/users/darkmatter/repos",
"events_url": "https://api.github.com/users/darkmatter/events{/privacy}",
"received_events_url": "https://api.github.com/users/darkmatter/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"html_url": "https://github.com/darkmatter/nixmac",
"description": "Home manager and nix-darwin that understands plain English",
"fork": false,
"url": "https://api.github.com/repos/darkmatter/nixmac",
"forks_url": "https://api.github.com/repos/darkmatter/nixmac/forks",
"keys_url": "https://api.github.com/repos/darkmatter/nixmac/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/darkmatter/nixmac/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/darkmatter/nixmac/teams",
"hooks_url": "https://api.github.com/repos/darkmatter/nixmac/hooks",
"issue_events_url": "https://api.github.com/repos/darkmatter/nixmac/issues/events{/number}",
"events_url": "https://api.github.com/repos/darkmatter/nixmac/events",
"assignees_url": "https://api.github.com/repos/darkmatter/nixmac/assignees{/user}",
"branches_url": "https://api.github.com/repos/darkmatter/nixmac/branches{/branch}",
"tags_url": "https://api.github.com/repos/darkmatter/nixmac/tags",
"blobs_url": "https://api.github.com/repos/darkmatter/nixmac/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/darkmatter/nixmac/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/darkmatter/nixmac/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/darkmatter/nixmac/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/darkmatter/nixmac/statuses/{sha}",
"languages_url": "https://api.github.com/repos/darkmatter/nixmac/languages",
"stargazers_url": "https://api.github.com/repos/darkmatter/nixmac/stargazers",
"contributors_url": "https://api.github.com/repos/darkmatter/nixmac/contributors",
"subscribers_url": "https://api.github.com/repos/darkmatter/nixmac/subscribers",
"subscription_url": "https://api.github.com/repos/darkmatter/nixmac/subscription",
"commits_url": "https://api.github.com/repos/darkmatter/nixmac/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/darkmatter/nixmac/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/darkmatter/nixmac/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/darkmatter/nixmac/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/darkmatter/nixmac/contents/{+path}",
"compare_url": "https://api.github.com/repos/darkmatter/nixmac/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/darkmatter/nixmac/merges",
"archive_url": "https://api.github.com/repos/darkmatter/nixmac/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/darkmatter/nixmac/downloads",
"issues_url": "https://api.github.com/repos/darkmatter/nixmac/issues{/number}",
"pulls_url": "https://api.github.com/repos/darkmatter/nixmac/pulls{/number}",
"milestones_url": "https://api.github.com/repos/darkmatter/nixmac/milestones{/number}",
"notifications_url": "https://api.github.com/repos/darkmatter/nixmac/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/darkmatter/nixmac/labels{/name}",
"releases_url": "https://api.github.com/repos/darkmatter/nixmac/releases{/id}",
"deployments_url": "https://api.github.com/repos/darkmatter/nixmac/deployments",
"created_at": "2026-04-14T00:37:13Z",
"updated_at": "2026-06-01T06:15:50Z",
"pushed_at": "2026-06-02T04:25:03Z",
"git_url": "git://github.com/darkmatter/nixmac.git",
"ssh_url": "git@github.com:darkmatter/nixmac.git",
"clone_url": "https://github.com/darkmatter/nixmac.git",
"svn_url": "https://github.com/darkmatter/nixmac",
"homepage": "https://nixmac.com",
"size": 679049,
"stargazers_count": 5,
"watchers_count": 5,
"language": "Rust",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"has_discussions": false,
"forks_count": 1,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 90,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"has_pull_requests": true,
"pull_request_creation_policy": "all",
"topics": [
"home-manager",
"nix",
"nix-darwin",
"nix-flake",
"opencode"
],
"visibility": "public",
"forks": 1,
"open_issues": 90,
"watchers": 5,
"default_branch": "develop"
}
},
"_links": {
"self": {
"href": "https://api.github.com/repos/darkmatter/nixmac/pulls/274"
},
"html": {
"href": "https://github.com/darkmatter/nixmac/pull/274"
},
"issue": {
"href": "https://api.github.com/repos/darkmatter/nixmac/issues/274"
},
"comments": {
"href": "https://api.github.com/repos/darkmatter/nixmac/issues/274/comments"
},
"review_comments": {
"href": "https://api.github.com/repos/darkmatter/nixmac/pulls/274/comments"
},
"review_comment": {
"href": "https://api.github.com/repos/darkmatter/nixmac/pulls/comments{/number}"
},
"commits": {
"href": "https://api.github.com/repos/darkmatter/nixmac/pulls/274/commits"
},
"statuses": {
"href": "https://api.github.com/repos/darkmatter/nixmac/statuses/596b117a6d03617358d0a89fe8c9c49eba334bc0"
}
},
"author_association": "COLLABORATOR",
"auto_merge": null,
"assignee": null,
"active_lock_reason": null
},
"thread": {
"node_id": "PRRT_kwDOSB6EzM6GUNYS",
"comments": [
{
"url": "https://api.github.com/repos/darkmatter/nixmac/pulls/comments/3338704691",
"pull_request_review_id": 4406524522,
"id": 3338704691,
"node_id": "PRRC_kwDOSB6EzM7HAJcz",
"diff_hunk": "@@ -9,166 +9,6 @@\n //! `Change.line_count` preserves the full hunk size.\n \n use crate::sqlite_types::Change;\n-use sha2::{Digest, Sha256};\n-\n-/// Lines kept in `Change.diff` for display. The hash uses the full hunk.\n-const DIFF_EXCERPT_LINES: usize = 60;\n-\n-/// Parse a unified diff string into one [`Change`] per file-hunk.\n-///\n-/// `created_at` is a Unix timestamp (seconds) forwarded to every returned struct.\n-/// The `id` field is always `0`; callers assign real ids on DB insert.\n-#[allow(clippy::manual_strip)]\n-pub fn changes_from_diff(diff: &str, created_at: i64, truncate_diffs: bool) -> Vec<Change> {\n- let mut changes = Vec::new();\n- let mut current_file: Option<String> = None;\n- let mut current_hunk: Option<String> = None;\n-\n- for line in diff.lines() {\n- if line.starts_with(\"diff --git \") {\n- flush(\n- &mut changes,\n- ¤t_file,\n- &mut current_hunk,\n- created_at,\n- truncate_diffs,\n- );\n- // \"diff --git is, always present with filenames for a/ and b/ paths.\n- current_file = line\n- .rfind(\" b/\")\n- .and_then(|i| line.get(i + 3..))\n- .map(str::to_string);\n- } else if let Some(path) = line.strip_prefix(\"+++ b/\") {\n- // Overrides the header value; more reliable for renames.\n- current_file = Some(path.to_string());\n- } else if line.starts_with(\"@@ \") {\n- flush(\n- &mut changes,\n- ¤t_file,\n- &mut current_hunk,\n- created_at,\n- truncate_diffs,\n- );\n- current_hunk = Some(line.to_string());\n- } else if let Some(ref mut hunk) = current_hunk {\n- hunk.push('\\n');\n- hunk.push_str(line);\n- }\n- }\n- flush(\n- &mut changes,\n- ¤t_file,\n- &mut current_hunk,\n- created_at,\n- truncate_diffs,\n- );\n-\n- changes\n-}\n-\n-fn flush(\n- out: &mut Vec<Change>,\n- filename: &Option<String>,\n- hunk: &mut Option<String>,\n- created_at: i64,\n- truncate_diffs: bool,\n-) {\n- if let (Some(f), Some(h)) = (filename.as_deref(), hunk.take()) {\n- if !h.trim().is_empty() {\n- let line_count = h.lines().count() as i64;\n- let hash = hunk_hash(f, &h); // full diff before truncation\n- let diff = if truncate_diffs {\n- truncate_excerpt(&h)\n- } else {\n- h\n- };\n- out.push(Change {\n- id: 0,\n- hash,\n- filename: f.to_string(),\n- diff,\n- line_count,\n- created_at,\n- own_summary_id: None,\n- });\n- }\n- }\n-}\n-\n-fn truncate_excerpt(hunk: &str) -> String {\n- let mut lines = hunk.lines();\n- let head: Vec<&str> = lines.by_ref().take(DIFF_EXCERPT_LINES).collect();\n- if lines.next().is_some() {\n- format!(\"{}\\n... [truncated]\", head.join(\"\\n\"))\n- } else {\n- head.join(\"\\n\")\n- }\n-}\n-\n-/// Returns true for hunks that should be excluded from AI analysis.\n-///\n-/// Two categories:\n-/// - **Security**: credential files, secrets directories, SOPS-encrypted content,\n-/// PEM blocks — content that should not leave the local machine via a remote\n-/// provider, and that the model cannot meaningfully interpret anyway.\n-/// - **Model safety**: lock files, long opaque base64/hex blobs — content that\n-/// adds no semantic signal and can cause Ollama's JSON mode to latch onto\n-/// embedded structures and output them verbatim instead of the expected schema.\n-pub fn is_sensitive_or_opaque(change: &Change) -> bool {\n- let fname = &change.filename;\n- let basename = fname.rsplit('/').next().unwrap_or(fname);\n-\n- // Lock file extensions (.lock covers flake.lock, Cargo.lock, yarn.lock, etc.)\n- if fname.ends_with(\".lock\") || fname.ends_with(\".lockb\") {\n- return true;\n- }\n- // Lock files that don't use a .lock extension\n- if matches!(\n- basename,\n- \"package-lock.json\" | \"pnpm-lock.yaml\" | \"npm-shrinkwrap.json\"\n- ) {\n- return true;\n- }\n- // Credential / secret files\n- if fname.ends_with(\".token\") || fname.ends_with(\".age\") {\n- return true;\n- }\n- // Secrets directories\n- if fname.starts_with(\"secrets/\") || fname.contains(\"/secrets/\") {\n- return true;\n- }\n- // SOPS encrypted values (any algorithm — ENC[ is the universal SOPS prefix)\n- if change.diff.contains(\"ENC[\") {\n- return true;\n- }\n- // PEM / age encrypted blocks\n- if change.diff.contains(\"-----BEGIN \") {\n- return true;\n- }\n- // Source maps — never meaningful content\n- if fname.ends_with(\".js.map\") || fname.ends_with(\".ts.map\") {\n- return true;\n- }\n- // Minified JS/CSS\n- if fname.ends_with(\".min.js\") || fname.ends_with(\".min.css\") {\n- return true;\n- }\n- // Raycast extension bundles (files/config/raycast/extensions/<uuid>/...)\n- if fname.contains(\"/raycast/extensions/\") {\n- return true;\n- }\n- // Any line that is a long opaque base64/hex blob (data URIs, raw binary, etc.).\n- // Ollama's JSON mode can latch onto JSON containing these and output it verbatim,\n- // exhausting the token budget mid-string.\n- change.diff.lines().any(|line| {\n- let stripped = line.trim_start_matches(['+', '-', ' ']);\n- stripped.len() > 200\n- && stripped\n- .chars()\n- .all(|c| matches!(c, 'A'..='Z' | 'a'..='z' | '0'..='9' | '+' | '/' | '=' | '\\r'))\n- })\n-}\n-\n /// Characters retained when hashes are shortened for model prompts.",
"path": "apps/native/src-tauri/src/git/changes_from_diff.rs",
"commit_id": "596b117a6d03617358d0a89fe8c9c49eba334bc0",
"original_commit_id": "596b117a6d03617358d0a89fe8c9c49eba334bc0",
"user": {
"login": "Copilot",
"id": 175728472,
"node_id": "BOT_kgDOCnlnWA",
"avatar_url": "https://avatars.githubusercontent.com/in/946600?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Copilot",
"html_url": "https://github.com/apps/copilot-pull-request-reviewer",
"followers_url": "https://api.github.com/users/Copilot/followers",
"following_url": "https://api.github.com/users/Copilot/following{/other_user}",
"gists_url": "https://api.github.com/users/Copilot/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Copilot/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Copilot/subscriptions",
"organizations_url": "https://api.github.com/users/Copilot/orgs",
"repos_url": "https://api.github.com/users/Copilot/repos",
"events_url": "https://api.github.com/users/Copilot/events{/privacy}",
"received_events_url": "https://api.github.com/users/Copilot/received_events",
"type": "Bot",
"user_view_type": "public",
"site_admin": false
},
"body": "This module’s header docs still describe unified-diff parsing and reference `DIFF_EXCERPT_LINES`, but the parsing logic was removed and the module now only provides hash helpers (`SHORT_HASH_LEN`, `with_short_hashes`, `filter_by_hashes`). Updating the docs will prevent future contributors from looking here for diff parsing (or assuming old truncation/hash semantics still apply).",
"created_at": "2026-06-02T04:33:31Z",
"updated_at": "2026-06-02T04:33:32Z",
"html_url": "https://github.com/darkmatter/nixmac/pull/274#discussion_r3338704691",
"pull_request_url": "https://api.github.com/repos/darkmatter/nixmac/pulls/274",
"_links": {
"self": {
"href": "https://api.github.com/repos/darkmatter/nixmac/pulls/comments/3338704691"
},
"html": {
"href": "https://github.com/darkmatter/nixmac/pull/274#discussion_r3338704691"
},
"pull_request": {
"href": "https://api.github.com/repos/darkmatter/nixmac/pulls/274"
}
},
"reactions": {
"url": "https://api.github.com/repos/darkmatter/nixmac/pulls/comments/3338704691/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"start_line": 9,
"original_start_line": 9,
"start_side": "RIGHT",
"line": 12,
"original_line": 12,
"side": "RIGHT",
"author_association": "CONTRIBUTOR",
"original_position": 164,
"position": 164,
"subject_type": "line"
},
{
"url": "https://api.github.com/repos/darkmatter/nixmac/pulls/comments/3338899097",
"pull_request_review_id": 4406826448,
"id": 3338899097,
"node_id": "PRRC_kwDOSB6EzM7HA46Z",
"diff_hunk": "@@ -9,166 +9,6 @@\n //! `Change.line_count` preserves the full hunk size.\n \n use crate::sqlite_types::Change;\n-use sha2::{Digest, Sha256};\n-\n-/// Lines kept in `Change.diff` for display. The hash uses the full hunk.\n-const DIFF_EXCERPT_LINES: usize = 60;\n-\n-/// Parse a unified diff string into one [`Change`] per file-hunk.\n-///\n-/// `created_at` is a Unix timestamp (seconds) forwarded to every returned struct.\n-/// The `id` field is always `0`; callers assign real ids on DB insert.\n-#[allow(clippy::manual_strip)]\n-pub fn changes_from_diff(diff: &str, created_at: i64, truncate_diffs: bool) -> Vec<Change> {\n- let mut changes = Vec::new();\n- let mut current_file: Option<String> = None;\n- let mut current_hunk: Option<String> = None;\n-\n- for line in diff.lines() {\n- if line.starts_with(\"diff --git \") {\n- flush(\n- &mut changes,\n- ¤t_file,\n- &mut current_hunk,\n- created_at,\n- truncate_diffs,\n- );\n- // \"diff --git is, always present with filenames for a/ and b/ paths.\n- current_file = line\n- .rfind(\" b/\")\n- .and_then(|i| line.get(i + 3..))\n- .map(str::to_string);\n- } else if let Some(path) = line.strip_prefix(\"+++ b/\") {\n- // Overrides the header value; more reliable for renames.\n- current_file = Some(path.to_string());\n- } else if line.starts_with(\"@@ \") {\n- flush(\n- &mut changes,\n- ¤t_file,\n- &mut current_hunk,\n- created_at,\n- truncate_diffs,\n- );\n- current_hunk = Some(line.to_string());\n- } else if let Some(ref mut hunk) = current_hunk {\n- hunk.push('\\n');\n- hunk.push_str(line);\n- }\n- }\n- flush(\n- &mut changes,\n- ¤t_file,\n- &mut current_hunk,\n- created_at,\n- truncate_diffs,\n- );\n-\n- changes\n-}\n-\n-fn flush(\n- out: &mut Vec<Change>,\n- filename: &Option<String>,\n- hunk: &mut Option<String>,\n- created_at: i64,\n- truncate_diffs: bool,\n-) {\n- if let (Some(f), Some(h)) = (filename.as_deref(), hunk.take()) {\n- if !h.trim().is_empty() {\n- let line_count = h.lines().count() as i64;\n- let hash = hunk_hash(f, &h); // full diff before truncation\n- let diff = if truncate_diffs {\n- truncate_excerpt(&h)\n- } else {\n- h\n- };\n- out.push(Change {\n- id: 0,\n- hash,\n- filename: f.to_string(),\n- diff,\n- line_count,\n- created_at,\n- own_summary_id: None,\n- });\n- }\n- }\n-}\n-\n-fn truncate_excerpt(hunk: &str) -> String {\n- let mut lines = hunk.lines();\n- let head: Vec<&str> = lines.by_ref().take(DIFF_EXCERPT_LINES).collect();\n- if lines.next().is_some() {\n- format!(\"{}\\n... [truncated]\", head.join(\"\\n\"))\n- } else {\n- head.join(\"\\n\")\n- }\n-}\n-\n-/// Returns true for hunks that should be excluded from AI analysis.\n-///\n-/// Two categories:\n-/// - **Security**: credential files, secrets directories, SOPS-encrypted content,\n-/// PEM blocks — content that should not leave the local machine via a remote\n-/// provider, and that the model cannot meaningfully interpret anyway.\n-/// - **Model safety**: lock files, long opaque base64/hex blobs — content that\n-/// adds no semantic signal and can cause Ollama's JSON mode to latch onto\n-/// embedded structures and output them verbatim instead of the expected schema.\n-pub fn is_sensitive_or_opaque(change: &Change) -> bool {\n- let fname = &change.filename;\n- let basename = fname.rsplit('/').next().unwrap_or(fname);\n-\n- // Lock file extensions (.lock covers flake.lock, Cargo.lock, yarn.lock, etc.)\n- if fname.ends_with(\".lock\") || fname.ends_with(\".lockb\") {\n- return true;\n- }\n- // Lock files that don't use a .lock extension\n- if matches!(\n- basename,\n- \"package-lock.json\" | \"pnpm-lock.yaml\" | \"npm-shrinkwrap.json\"\n- ) {\n- return true;\n- }\n- // Credential / secret files\n- if fname.ends_with(\".token\") || fname.ends_with(\".age\") {\n- return true;\n- }\n- // Secrets directories\n- if fname.starts_with(\"secrets/\") || fname.contains(\"/secrets/\") {\n- return true;\n- }\n- // SOPS encrypted values (any algorithm — ENC[ is the universal SOPS prefix)\n- if change.diff.contains(\"ENC[\") {\n- return true;\n- }\n- // PEM / age encrypted blocks\n- if change.diff.contains(\"-----BEGIN \") {\n- return true;\n- }\n- // Source maps — never meaningful content\n- if fname.ends_with(\".js.map\") || fname.ends_with(\".ts.map\") {\n- return true;\n- }\n- // Minified JS/CSS\n- if fname.ends_with(\".min.js\") || fname.ends_with(\".min.css\") {\n- return true;\n- }\n- // Raycast extension bundles (files/config/raycast/extensions/<uuid>/...)\n- if fname.contains(\"/raycast/extensions/\") {\n- return true;\n- }\n- // Any line that is a long opaque base64/hex blob (data URIs, raw binary, etc.).\n- // Ollama's JSON mode can latch onto JSON containing these and output it verbatim,\n- // exhausting the token budget mid-string.\n- change.diff.lines().any(|line| {\n- let stripped = line.trim_start_matches(['+', '-', ' ']);\n- stripped.len() > 200\n- && stripped\n- .chars()\n- .all(|c| matches!(c, 'A'..='Z' | 'a'..='z' | '0'..='9' | '+' | '/' | '=' | '\\r'))\n- })\n-}\n-\n /// Characters retained when hashes are shortened for model prompts.",
"path": "apps/native/src-tauri/src/git/changes_from_diff.rs",
"commit_id": "596b117a6d03617358d0a89fe8c9c49eba334bc0",
"original_commit_id": "596b117a6d03617358d0a89fe8c9c49eba334bc0",
"user": {
"login": "scottmcmaster",
"id": 3137688,
"node_id": "MDQ6VXNlcjMxMzc2ODg=",
"avatar_url": "https://avatars.githubusercontent.com/u/3137688?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/scottmcmaster",
"html_url": "https://github.com/scottmcmaster",
"followers_url": "https://api.github.com/users/scottmcmaster/followers",
"following_url": "https://api.github.com/users/scottmcmaster/following{/other_user}",
"gists_url": "https://api.github.com/users/scottmcmaster/gists{/gist_id}",
"starred_url": "https://api.github.com/users/scottmcmaster/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/scottmcmaster/subscriptions",
"organizations_url": "https://api.github.com/users/scottmcmaster/orgs",
"repos_url": "https://api.github.com/users/scottmcmaster/repos",
"events_url": "https://api.github.com/users/scottmcmaster/events{/privacy}",
"received_events_url": "https://api.github.com/users/scottmcmaster/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"body": "Changed. Ideally I was planning to get rid of this file entirely in the near-future.",
"created_at": "2026-06-02T05:33:50Z",
"updated_at": "2026-06-02T05:33:51Z",
"html_url": "https://github.com/darkmatter/nixmac/pull/274#discussion_r3338899097",
"pull_request_url": "https://api.github.com/repos/darkmatter/nixmac/pulls/274",
"_links": {
"self": {
"href": "https://api.github.com/repos/darkmatter/nixmac/pulls/comments/3338899097"
},
"html": {
"href": "https://github.com/darkmatter/nixmac/pull/274#discussion_r3338899097"
},
"pull_request": {
"href": "https://api.github.com/repos/darkmatter/nixmac/pulls/274"
}
},
"reactions": {
"url": "https://api.github.com/repos/darkmatter/nixmac/pulls/comments/3338899097/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"start_line": 9,
"original_start_line": 9,
"start_side": "RIGHT",
"line": 12,
"original_line": 12,
"side": "RIGHT",
"in_reply_to_id": 3338704691,
"author_association": "COLLABORATOR",
"original_position": 164,
"position": 164,
"subject_type": "line"
}
]
},
"updated_at": "2026-06-02T13:33:52+08:00",
"repository": {
"id": 1209959628,
"node_id": "R_kgDOSB6EzA",
"name": "nixmac",
"full_name": "darkmatter/nixmac",
"private": false,
"owner": {
"login": "darkmatter",
"id": 17834193,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE3ODM0MTkz",
"avatar_url": "https://avatars.githubusercontent.com/u/17834193?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/darkmatter",
"html_url": "https://github.com/darkmatter",
"followers_url": "https://api.github.com/users/darkmatter/followers",
"following_url": "https://api.github.com/users/darkmatter/following{/other_user}",
"gists_url": "https://api.github.com/users/darkmatter/gists{/gist_id}",
"starred_url": "https://api.github.com/users/darkmatter/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/darkmatter/subscriptions",
"organizations_url": "https://api.github.com/users/darkmatter/orgs",
"repos_url": "https://api.github.com/users/darkmatter/repos",
"events_url": "https://api.github.com/users/darkmatter/events{/privacy}",
"received_events_url": "https://api.github.com/users/darkmatter/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"html_url": "https://github.com/darkmatter/nixmac",
"description": "Home manager and nix-darwin that understands plain English",
"fork": false,
"url": "https://api.github.com/repos/darkmatter/nixmac",
"forks_url": "https://api.github.com/repos/darkmatter/nixmac/forks",
"keys_url": "https://api.github.com/repos/darkmatter/nixmac/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/darkmatter/nixmac/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/darkmatter/nixmac/teams",
"hooks_url": "https://api.github.com/repos/darkmatter/nixmac/hooks",
"issue_events_url": "https://api.github.com/repos/darkmatter/nixmac/issues/events{/number}",
"events_url": "https://api.github.com/repos/darkmatter/nixmac/events",
"assignees_url": "https://api.github.com/repos/darkmatter/nixmac/assignees{/user}",
"branches_url": "https://api.github.com/repos/darkmatter/nixmac/branches{/branch}",
"tags_url": "https://api.github.com/repos/darkmatter/nixmac/tags",
"blobs_url": "https://api.github.com/repos/darkmatter/nixmac/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/darkmatter/nixmac/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/darkmatter/nixmac/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/darkmatter/nixmac/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/darkmatter/nixmac/statuses/{sha}",
"languages_url": "https://api.github.com/repos/darkmatter/nixmac/languages",
"stargazers_url": "https://api.github.com/repos/darkmatter/nixmac/stargazers",
"contributors_url": "https://api.github.com/repos/darkmatter/nixmac/contributors",
"subscribers_url": "https://api.github.com/repos/darkmatter/nixmac/subscribers",
"subscription_url": "https://api.github.com/repos/darkmatter/nixmac/subscription",
"commits_url": "https://api.github.com/repos/darkmatter/nixmac/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/darkmatter/nixmac/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/darkmatter/nixmac/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/darkmatter/nixmac/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/darkmatter/nixmac/contents/{+path}",
"compare_url": "https://api.github.com/repos/darkmatter/nixmac/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/darkmatter/nixmac/merges",
"archive_url": "https://api.github.com/repos/darkmatter/nixmac/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/darkmatter/nixmac/downloads",
"issues_url": "https://api.github.com/repos/darkmatter/nixmac/issues{/number}",
"pulls_url": "https://api.github.com/repos/darkmatter/nixmac/pulls{/number}",
"milestones_url": "https://api.github.com/repos/darkmatter/nixmac/milestones{/number}",
"notifications_url": "https://api.github.com/repos/darkmatter/nixmac/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/darkmatter/nixmac/labels{/name}",
"releases_url": "https://api.github.com/repos/darkmatter/nixmac/releases{/id}",
"deployments_url": "https://api.github.com/repos/darkmatter/nixmac/deployments",
"created_at": "2026-04-14T00:37:13Z",
"updated_at": "2026-06-01T06:15:50Z",
"pushed_at": "2026-06-02T04:25:03Z",
"git_url": "git://github.com/darkmatter/nixmac.git",
"ssh_url": "git@github.com:darkmatter/nixmac.git",
"clone_url": "https://github.com/darkmatter/nixmac.git",
"svn_url": "https://github.com/darkmatter/nixmac",
"homepage": "https://nixmac.com",
"size": 679049,
"stargazers_count": 5,
"watchers_count": 5,
"language": "Rust",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"has_discussions": false,
"forks_count": 1,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 90,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"has_pull_requests": true,
"pull_request_creation_policy": "all",
"topics": [
"home-manager",
"nix",
"nix-darwin",
"nix-flake",
"opencode"
],
"visibility": "public",
"forks": 1,
"open_issues": 90,
"watchers": 5,
"default_branch": "develop",
"custom_properties": {}
},
"organization": {
"login": "darkmatter",
"id": 17834193,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE3ODM0MTkz",
"url": "https://api.github.com/orgs/darkmatter",
"repos_url": "https://api.github.com/orgs/darkmatter/repos",
"events_url": "https://api.github.com/orgs/darkmatter/events",
"hooks_url": "https://api.github.com/orgs/darkmatter/hooks",
"issues_url": "https://api.github.com/orgs/darkmatter/issues",
"members_url": "https://api.github.com/orgs/darkmatter/members{/member}",
"public_members_url": "https://api.github.com/orgs/darkmatter/public_members{/member}",
"avatar_url": "https://avatars.githubusercontent.com/u/17834193?v=4",
"description": ""
},
"enterprise": {
"id": 469843,
"slug": "darkmatter",
"name": "darkmatter",
"node_id": "E_kgDOAAcrUw",
"avatar_url": "https://avatars.githubusercontent.com/b/469843?v=4",
"description": "",
"website_url": "darkmatter.io",
"html_url": "https://github.com/enterprises/darkmatter",
"created_at": "2025-09-07T16:01:00Z",
"updated_at": "2026-05-09T15:34:55Z"
},
"sender": {
"login": "scottmcmaster",
"id": 3137688,
"node_id": "MDQ6VXNlcjMxMzc2ODg=",
"avatar_url": "https://avatars.githubusercontent.com/u/3137688?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/scottmcmaster",
"html_url": "https://github.com/scottmcmaster",
"followers_url": "https://api.github.com/users/scottmcmaster/followers",
"following_url": "https://api.github.com/users/scottmcmaster/following{/other_user}",
"gists_url": "https://api.github.com/users/scottmcmaster/gists{/gist_id}",
"starred_url": "https://api.github.com/users/scottmcmaster/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/scottmcmaster/subscriptions",
"organizations_url": "https://api.github.com/users/scottmcmaster/orgs",
"repos_url": "https://api.github.com/users/scottmcmaster/repos",
"events_url": "https://api.github.com/users/scottmcmaster/events{/privacy}",
"received_events_url": "https://api.github.com/users/scottmcmaster/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"installation": {
"id": 131074261,
"node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMTMxMDc0MjYx"
}
}