Skip to content

farnoy/code-comment-splitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

code-comment-splitter

Split comments into separate commits. When you add code and comments together, use this with jj split to commit the code changes first while leaving comment-only changes in your working copy. This lets you stage, squash, and manipulate documentation separately from logic changes.

Quick Start

No installation needed! Run directly from JSR with Deno:

# Add to your jj config (~/.config/jj/config.toml)
[merge-tools.split-comments]
program = "deno"
edit-args = [
  "run",
  "--allow-read=/tmp",
  "--allow-write=/tmp",
  "--allow-env=JJ_SPLIT_LOG",
  "jsr:@farnoy/jj-comment-splitter",
  "$left",
  "$right"
]

Then use it:

jj split --tool split-comments

What it does

Running jj split --tool split-comments creates one commit with non-comment changes and leaves comment-only changes in your working copy.

Supports // and # style comments.

Permissions

The tool needs:

  • --allow-read=/tmp - jj creates temporary directories in /tmp for the split operation
  • --allow-write=/tmp - To write the filtered changes back
  • --allow-env=JJ_SPLIT_LOG - To read the optional JJ_SPLIT_LOG environment variable for verbose output

Verbose logging

Set JJ_SPLIT_LOG=1 to see detailed output:

JJ_SPLIT_LOG=1 jj split --tool split-comments

Development

Running locally

Clone the repository and run with Deno:

git clone https://github.com/farnoy/code-comment-splitter.git
cd code-comment-splitter

# Run directly
deno task start <leftDir> <rightDir>

# Or with full permissions
deno run --allow-read --allow-write --allow-env src/cli/jj-merge-tool.ts <leftDir> <rightDir>

Testing

deno task test      # Run tests
deno task check     # Type check
deno task dev       # Watch mode

Local jj config

To use your local version instead of GitHub:

[merge-tools.split-comments]
program = "deno"
edit-args = [
  "run",
  "--allow-read=/tmp",
  "--allow-write=/tmp",
  "--allow-env=JJ_SPLIT_LOG",
  "/absolute/path/to/src/cli/jj-merge-tool.ts",
  "$left",
  "$right"
]

Project structure

code-comment-splitter/
├── src/
│   ├── cli/jj-merge-tool.ts           # CLI entry point
│   ├── lib/splitNonComment.ts         # Core logic (LCS-based diff algorithm)
│   └── __tests__/splitNonComment.test.ts
└── deno.json

License

ISC

About

jujutsu merge tool to split out comments from the code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published