Skip to content

Commit

Permalink
changes from notes to directory
Browse files Browse the repository at this point in the history
  • Loading branch information
carpe-diem committed Dec 27, 2024
1 parent ab582c7 commit 88c50bf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "notesync"
name = "gitsync"
version = "0.1.0"
edition = "2021"

Expand Down
45 changes: 24 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Notes Sync
# GitSync

![Rust CI](https://github.com/carpe-diem/notes-sync/actions/workflows/rust.yml/badge.svg)
<!-- [![Crates.io](https://img.shields.io/crates/v/notesync.svg)](https://crates.io/crates/notesync) -->
<!-- [![Documentation](https://docs.rs/notesync/badge.svg)](https://docs.rs/notesync) -->
![Rust CI](https://github.com/carpe-diem/git-sync/actions/workflows/rust.yml/badge.svg)
<!-- [![Crates.io](https://img.shields.io/crates/v/gitsync.svg)](https://crates.io/crates/gitsync) -->
<!-- [![Documentation](https://docs.rs/gitsync/badge.svg)](https://docs.rs/gitsync) -->
[![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg)](LICENSE)
[![Rust Version](https://img.shields.io/badge/rust-1.70%2B-orange.svg)](https://www.rust-lang.org)
[![dependency status](https://deps.rs/repo/github/carpe-diem/notes-sync/status.svg)](https://deps.rs/repo/github/carpe-diem/notes-sync)
<!-- [![codecov](https://codecov.io/gh/carpe-diem/notes-sync/branch/main/graph/badge.svg)](https://codecov.io/gh/carpe-diem/notes-sync) -->
[![dependency status](https://deps.rs/repo/github/carpe-diem/git-sync/status.svg)](https://deps.rs/repo/github/carpe-diem/git-sync)
<!-- [![codecov](https://codecov.io/gh/carpe-diem/git-sync/branch/main/graph/badge.svg)](https://codecov.io/gh/carpe-diem/git-sync) -->

A simple CLI tool to synchronize any directory with GitHub. Keep your files backed up and accessible across multiple devices using Git as the synchronization mechanism.

A simple application to synchronize your notes with GitHub. Keep your notes backed up and accessible across multiple devices using Git as the synchronization mechanism.

## Features
- ...
- Synchronization with GitHub repositories
- Two-way sync between local directory and remote repository
- Simple configuration and setup

## TODO
- Automatic synchronization with GitHub repositories.
Expand All @@ -20,15 +23,15 @@ A simple application to synchronize your notes with GitHub. Keep your notes back

## Description

Notes Sync is a tool designed to help you maintain your notes organized and synchronized using GitHub as a backend. It watches for changes in your local notes directory and automatically commits and pushes changes to your configured GitHub repository.
GitSync is a tool designed to help you maintain your notes organized and synchronized using GitHub as a backend. It watches for changes in your local notes directory and automatically commits and pushes changes to your configured GitHub repository.

## Usage
```bash
# Initial setup
notesync setup
gitsync setup

# Sync your notes
notesync sync
gitsync sync
```

## Installation
Expand All @@ -40,27 +43,27 @@ notesync sync
2. Clone and build the project:
```bash
git clone [repository-url]
cd notes-sync
cd git-sync
cargo build --release
```

3. The binary will be available at `target/release/notesync`
3. The binary will be available at `target/release/gitsync`

## Configuration
Run the setup command and follow the prompts:
```bash
notesync setup
gitsync setup
```

You'll need to provide:
- GitHub Personal Access Token (with repo permissions)
- GitHub repository (format: username/repo)
- Path to your Notes folder
- Path to your directory to sync

## Project Structure

```
notes-sync
git-sync
├── .github // GitHub Actions configuration
├── src
│ ├── main.rs // Application entry point
Expand Down Expand Up @@ -105,15 +108,15 @@ pre-commit run --all-files

### Building
```bash
cargo build # Debug build
cargo build --release # Release build
cargo build # Debug build
cargo build --release # Release build
```

### Testing
```bash
cargo test # Run all tests
cargo test config # Run tests for config module only
cargo test -- --nocapture # Run tests and show println output
cargo test # Run all tests
cargo test config # Run tests for config module only
cargo test -- --nocapture # Run tests and show println output
```

### Running in Development
Expand Down
22 changes: 11 additions & 11 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::io::{self, Write};
pub struct Config {
pub github_token: String,
pub github_repo: String,
pub notes_path: String,
pub directory_path: String,
}

impl Config {
Expand All @@ -28,7 +28,7 @@ impl Config {
let existing_config = Self::load()?.unwrap_or(Config {
github_token: String::new(),
github_repo: String::new(),
notes_path: String::new(),
directory_path: String::new(),
});

let config = Config {
Expand All @@ -40,9 +40,9 @@ impl Config {
"Enter repository (format: username/repo)",
&existing_config.github_repo,
)?,
notes_path: prompt_with_default(
"Enter path to your Notes folder",
&existing_config.notes_path,
directory_path: prompt_with_default(
"Enter path to your directory to sync",
&existing_config.directory_path,
)?,
};

Expand Down Expand Up @@ -111,15 +111,15 @@ mod tests {
let config = Config {
github_token: "test_token".to_string(),
github_repo: "user/repo".to_string(),
notes_path: "/path/to/notes".to_string(),
directory_path: "/path/to/notes".to_string(),
};

let serialized = serde_json::to_string(&config).unwrap();
let deserialized: Config = serde_json::from_str(&serialized).unwrap();

assert_eq!(config.github_token, deserialized.github_token);
assert_eq!(config.github_repo, deserialized.github_repo);
assert_eq!(config.notes_path, deserialized.notes_path);
assert_eq!(config.directory_path, deserialized.directory_path);
}

#[test]
Expand All @@ -132,7 +132,7 @@ mod tests {
let test_config = Config {
github_token: "temp_token".to_string(),
github_repo: "temp/repo".to_string(),
notes_path: "/temp/path".to_string(),
directory_path: "/temp/path".to_string(),
};

// Save config directly to temp file
Expand All @@ -146,7 +146,7 @@ mod tests {
// Verify contents
assert_eq!(test_config.github_token, loaded_config.github_token);
assert_eq!(test_config.github_repo, loaded_config.github_repo);
assert_eq!(test_config.notes_path, loaded_config.notes_path);
assert_eq!(test_config.directory_path, loaded_config.directory_path);

// TempDir will be automatically cleaned up when it goes out of scope
Ok(())
Expand Down Expand Up @@ -207,11 +207,11 @@ mod tests {
let config = Config {
github_token: String::new(),
github_repo: String::new(),
notes_path: String::new(),
directory_path: String::new(),
};

assert!(config.github_token.is_empty());
assert!(config.github_repo.is_empty());
assert!(config.notes_path.is_empty());
assert!(config.directory_path.is_empty());
}
}

0 comments on commit 88c50bf

Please sign in to comment.