claude-attribution 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.ts +31 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-attribution",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "AI code attribution tracking for Claude Code sessions — checkpoint-based line diff approach",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.ts CHANGED
@@ -50,18 +50,40 @@ switch (cmd) {
50
50
  case "post-commit":
51
51
  await import("./attribution/commit.ts");
52
52
  break;
53
- case "pre-push":
54
- try {
55
- await execFileAsync("git", [
56
- "push",
57
- "origin",
58
- "refs/notes/claude-attribution",
59
- ]);
60
- } catch {
61
- // Ignore — notes push failure must not block git push
53
+ case "pre-push": {
54
+ // Git passes pushed refs on stdin: "<local-ref> <local-sha> <remote-ref> <remote-sha>\n..."
55
+ // Skip notes push for tag-only and notes pushes to avoid SSH connection conflicts.
56
+ const stdin = await new Promise<string>((resolve) => {
57
+ let data = "";
58
+ process.stdin.setEncoding("utf8");
59
+ process.stdin.on("data", (chunk: string) => (data += chunk));
60
+ process.stdin.on("end", () => resolve(data));
61
+ });
62
+ const isBranchPush = stdin
63
+ .trim()
64
+ .split("\n")
65
+ .filter(Boolean)
66
+ .some((line) => {
67
+ const remoteRef = line.split(" ")[2] ?? "";
68
+ return (
69
+ !remoteRef.startsWith("refs/tags/") &&
70
+ !remoteRef.startsWith("refs/notes/")
71
+ );
72
+ });
73
+ if (isBranchPush) {
74
+ try {
75
+ await execFileAsync("git", [
76
+ "push",
77
+ "origin",
78
+ "refs/notes/claude-attribution",
79
+ ]);
80
+ } catch {
81
+ // Ignore — notes push failure must not block git push
82
+ }
62
83
  }
63
84
  process.exit(0);
64
85
  break;
86
+ }
65
87
  default:
66
88
  console.error(`Unknown hook: ${rest[0]}`);
67
89
  process.exit(1);