Skip to content

aniadev/codesync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codesync

Lightweight CLI for scanning local Git repositories and cloned repos from JSON.

Features

  • Scan a directory tree for Git repositories and export a summary to JSON.
  • Clone repositories from a JSON export into a target directory.
  • Preserve branch information when cloning; detached heads are marked.

Requirements

  • Rust (cargo)
  • Git

Build

Build the binary using cargo:

cargo build --release

Install locally:

cargo install --path .

Usage

The CLI supports two subcommands: scan and clone.

Scan a root directory and export repositories to JSON:

codesync scan --root ~/hdev/workspaces --depth 5 --output repos.json

Options:

  • --root (string): Root folder to scan. Defaults to ~/hdev/workspaces.
  • --depth (usize): Maximum depth to traverse when searching for .git directories. Defaults to 5.
  • --output (string): Output JSON filename. Defaults to repos.json.

Clone repositories defined in an export JSON into a target folder:

codesync clone --input repos.json --target ~/codespace

Options:

  • --input (string): Path to a JSON file exported by scan. Defaults to repos.json.
  • --target (string): Directory where repositories will be cloned. Defaults to ~/codespace.

JSON format

The exported file is a list of objects with the following shape:

[
  {
    "path": "relative/path/to/repo",
    "origin": "git@github.com:example/repo.git",
    "branch": "main"
  }
]
  • path: Relative path to the repository (relative to --root used during scanning).
  • origin: The origin remote URL for the repo.
  • branch: The current branch or detached if HEAD was detached.

Behavior & Notes

  • scan looks for .git directories under --root. Repositories without an origin remote are skipped.
  • scan stores paths relative to the provided --root argument.
  • clone creates parent directories if needed and skips cloning if a .git folder already exists.
  • If a branch is not detached, clone attempts to git checkout that branch after cloning.

Troubleshooting

  • Ensure git is installed and accessible in your PATH.
  • If cloning fails for a repo, it will be reported and the CLI continues with the next repo.
  • For private repositories, ensure you have correct SSH keys or appropriate authentication configured.

License

This repository does not include a license file. Add a LICENSE if you wish to define reuse terms.

Contributing

Contributions are welcome. Open an issue or a pull request with suggested changes or fixes.

Git setup

If you want to push this project to a remote repository (for example GitHub), run:

git remote add origin git@github.com:your-username/your-repo.git
git branch -M main
git push -u origin main

Replace git@github.com:your-username/your-repo.git with your remote repository URL.

macOS releases

You can produce macOS binaries for both Intel (x86_64) and Apple Silicon (aarch64), then create a universal binary.

Local build steps (macOS):

# Build for Intel
rustup target add x86_64-apple-darwin
cargo build --release --target x86_64-apple-darwin

# Build for Apple Silicon
rustup target add aarch64-apple-darwin
cargo build --release --target aarch64-apple-darwin

# Combine with lipo
lipo -create \
  target/x86_64-apple-darwin/release/codesync \
  target/aarch64-apple-darwin/release/codesync \
  -output dist/codesync
chmod +x dist/codesync
zip -j dist/codesync-macos-universal.zip dist/codesync

Or use the convenience script:

scripts/build_macos_universal.sh

CI (GitHub Actions):

  • A workflow is included at .github/workflows/release-macos.yml which builds both architectures on macOS runners, creates a universal binary, and publishes it when a tag is pushed (for example v1.0.0).

Signing and notarization

  • For distributing outside the App Store, consider signing and notarizing the binary. This requires a Mac developer account and the Apple notary tools; those steps are not included in this repository but can be integrated into the release workflow.

About

Lightweight CLI for scanning local Git repositories and cloned repos from JSON.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors