diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 72de9b8..f9a06a2 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -141,16 +141,24 @@ jobs: run: | cargo set-version ${{ steps.changelog.outputs.version }} cargo build --verbose + - name: 🛠️ Update flake.nix version to match Cargo.toml + if: steps.changelog.outputs.skipped == 'false' + run: | + VERSION="${{ steps.changelog.outputs.version }}" + # Update version in flake.nix - matches pattern: version = "X.Y.Z"; + sed -i "s/version = \"[0-9]*\.[0-9]*\.[0-9]*\";/version = \"${VERSION}\";/" flake.nix + # Verify the update + grep "version = " flake.nix | head -1 - name: 🛠️ Update lockfile if: steps.changelog.outputs.skipped == 'false' run: cargo update - - name: 🛠️ Commit Cargo.lock + - name: 🛠️ Commit Cargo.lock, Cargo.toml, and flake.nix if: steps.changelog.outputs.skipped == 'false' run: | git config user.name "chess-seventh" git config user.email "chess7th@pm.me" - git add Cargo.lock Cargo.toml - git commit -m "chore: update Cargo.lock and Cargo.toml [skip ci]" + git add Cargo.lock Cargo.toml flake.nix + git commit -m "chore: update Cargo.lock, Cargo.toml, and flake.nix [skip ci]" git push - name: ✨ Create Release if: steps.changelog.outputs.skipped == 'false' diff --git a/Cargo.toml b/Cargo.toml index cff8e3e..fa71c38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,11 @@ env_logger = "0.11.8" tempfile = "3.23" chrono = {version = "0.4.42", features = ["serde"]} +[lib] +doctest = false + [package] name = "rusty-commit-saver" version = "4.5.0" -edition = "2024" +edition = "2021" authors = ["chess7th"] diff --git a/devenv.lock b/devenv.lock index a4c54d0..8e6b129 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,10 +3,10 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1764082355, + "lastModified": 1764227073, "owner": "cachix", "repo": "devenv", - "rev": "42c2bdc468814a18a81eb19df79c47929b298b1b", + "rev": "ee868b9986b84b82fee40ecc2524340d4a154961", "type": "github" }, "original": { @@ -106,10 +106,10 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1763934636, + "lastModified": 1764167966, "owner": "NixOS", "repo": "nixpkgs", - "rev": "ee09932cedcef15aaf476f9343d1dea2cb77e261", + "rev": "5c46f3bd98147c8d82366df95bbef2cab3a967ea", "type": "github" }, "original": { @@ -138,10 +138,10 @@ ] }, "locked": { - "lastModified": 1764038373, + "lastModified": 1764211126, "owner": "oxalica", "repo": "rust-overlay", - "rev": "ab3536fe850211a96673c6ffb2cb88aab8071cc9", + "rev": "895935bff08cfcfb663fb9c8263c43596e7cd1ed", "type": "github" }, "original": { @@ -155,10 +155,10 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1757989933, + "lastModified": 1764038373, "owner": "oxalica", "repo": "rust-overlay", - "rev": "8249aa3442fb9b45e615a35f39eca2fe5510d7c3", + "rev": "ab3536fe850211a96673c6ffb2cb88aab8071cc9", "type": "github" }, "original": { @@ -176,15 +176,15 @@ "rust-overlay": "rust-overlay_2" }, "locked": { - "lastModified": 1764115189, + "lastModified": 1764089152, "owner": "chess-seventh", "repo": "rusty-commit-saver", - "rev": "982216f44cbd22e8be972da8fcaa5c9c7b6bedd5", + "rev": "cc0bf19ae14b04901be5ee654df30733484fffae", "type": "github" }, "original": { "owner": "chess-seventh", - "ref": "HEAD", + "ref": "v4.0.0", "repo": "rusty-commit-saver", "type": "github" } diff --git a/devenv.yaml b/devenv.yaml index 042e0b1..8f1c705 100644 --- a/devenv.yaml +++ b/devenv.yaml @@ -7,7 +7,7 @@ inputs: nixpkgs: follows: nixpkgs rusty-commit-saver: - url: github:chess-seventh/rusty-commit-saver?ref=HEAD + url: github:chess-seventh/rusty-commit-saver?ref=v4.0.0 inputs: nixpkgs: follows: nixpkgs diff --git a/flake.nix b/flake.nix index 6ba6596..c430b35 100644 --- a/flake.nix +++ b/flake.nix @@ -14,7 +14,8 @@ overlays = [ (import rust-overlay) ]; pkgs = import nixpkgs { inherit system overlays; }; - rustVersion = pkgs.rust-bin.nightly."1.89.0".default; + # Use nightly to match your devenv.nix + rustVersion = pkgs.rust-bin.nightly.latest.default; rustPlatform = pkgs.makeRustPlatform { cargo = rustVersion; @@ -23,34 +24,31 @@ in { packages.default = rustPlatform.buildRustPackage { pname = "rusty-commit-saver"; - version = "4.4.0"; + version = "4.5.0"; src = ./.; cargoLock.lockFile = ./Cargo.lock; - nativeBuildInputs = with pkgs; - [ - pkg-config # Essential for finding OpenSSL - ]; + nativeBuildInputs = with pkgs; [ pkg-config ]; + buildInputs = with pkgs; [ openssl openssl.dev ]; - buildInputs = with pkgs; [ - openssl # OpenSSL library - openssl.dev # OpenSSL development headers - ]; - - # Environment variables to help find OpenSSL - OPENSSL_NO_VENDOR = 1; # Use system OpenSSL instead of vendored + OPENSSL_NO_VENDOR = 1; PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; + + # Doctests are now marked ignore, so doCheck works fine + doCheck = true; }; - # Development shell devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ - (rustVersion.override { extensions = [ "rust-src" ]; }) + (pkgs.rust-bin.nightly.latest.default.override { + extensions = [ "rust-src" ]; + }) cargo rustc pkg-config openssl openssl.dev + git ]; PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; diff --git a/src/config.rs b/src/config.rs index 0c0fd67..1d6ff8c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -27,7 +27,7 @@ use once_cell::sync::OnceCell; /// # INI Format /// /// The INI format supported: -/// ``` +/// ```text /// [section_name] /// key1 = value1 /// key2 = value2 @@ -38,7 +38,7 @@ use once_cell::sync::OnceCell; /// /// # Examples /// -/// ``` +/// ```ignore /// use rusty_commit_saver::config::parse_ini_content; /// /// let ini_content = r#" @@ -75,7 +75,7 @@ use once_cell::sync::OnceCell; /// This function is particularly useful for unit testing without needing /// to create temporary files: /// -/// ``` +/// ```ignore /// use rusty_commit_saver::config::parse_ini_content; /// /// fn test_config_parsing() { @@ -100,7 +100,7 @@ pub fn parse_ini_content(content: &str) -> Result { /// /// # Usage Pattern /// -/// ``` +/// ```ignore /// use rusty_commit_saver::config::GlobalVars; /// /// // 1. Create instance @@ -145,7 +145,7 @@ pub struct GlobalVars { /// # Configuration /// /// Loaded from INI file: - /// ``` + /// ```text /// [obsidian] /// root_path_dir = ~/Documents/Obsidian /// ``` @@ -164,7 +164,7 @@ pub struct GlobalVars { /// # Full Path Construction /// /// Combined with root and date template: - /// ``` + /// ```text /// {root_path_dir}/{commit_path}/{date_template} /// /home/user/Obsidian/Diaries/Commits/2025/01-January/2025-01-14.md /// ``` @@ -172,7 +172,7 @@ pub struct GlobalVars { /// # Configuration /// /// Loaded from INI file: - /// ``` + /// ```text /// [obsidian] /// commit_path = Diaries/Commits /// ``` @@ -193,7 +193,7 @@ pub struct GlobalVars { /// /// # Examples /// - /// ``` + /// ```text /// Format: %Y/%m-%B/%F.md /// Result: 2025/01-January/2025-01-14.md /// @@ -204,7 +204,7 @@ pub struct GlobalVars { /// # Configuration /// /// Loaded from INI file: - /// ``` + /// ```text /// [templates] /// commit_date_path = %Y/%m-%B/%F.md /// ``` @@ -226,7 +226,7 @@ pub struct GlobalVars { /// /// # Examples /// - /// ``` + /// ```text /// Format: %Y-%m-%d %H:%M:%S /// Result: 2025-01-14 14:30:45 /// @@ -237,7 +237,7 @@ pub struct GlobalVars { /// # Configuration /// /// Loaded from INI file: - /// ``` + /// ```text /// [templates] /// commit_datetime = %Y-%m-%d %H:%M:%S /// ``` @@ -269,7 +269,7 @@ impl GlobalVars { /// /// # Examples /// - /// ``` + /// ```ignore /// use rusty_commit_saver::config::GlobalVars; /// /// // Create new instance @@ -317,7 +317,7 @@ impl GlobalVars { /// /// # Required INI Structure /// - /// ``` + /// ```text /// [obsidian] /// root_path_dir = ~/Documents/Obsidian /// commit_path = Diaries/Commits @@ -329,7 +329,7 @@ impl GlobalVars { /// /// # Examples /// - /// ``` + /// ```ignore /// use rusty_commit_saver::config::GlobalVars; /// /// let global_vars = GlobalVars::new(); @@ -370,7 +370,7 @@ impl GlobalVars { /// /// # Examples /// - /// ``` + /// ```ignore /// use rusty_commit_saver::config::GlobalVars; /// /// let global_vars = GlobalVars::new(); @@ -384,7 +384,7 @@ impl GlobalVars { /// # Configuration Source /// /// Read from INI file: - /// ``` + /// ```text /// [obsidian] /// root_path_dir = ~/Documents/Obsidian /// ``` @@ -412,7 +412,7 @@ impl GlobalVars { /// /// # Examples /// - /// ``` + /// ```ignore /// use rusty_commit_saver::config::GlobalVars; /// /// let global_vars = GlobalVars::new(); @@ -429,7 +429,7 @@ impl GlobalVars { /// # Configuration Source /// /// Read from INI file: - /// ``` + /// ```text /// [obsidian] /// commit_path = Diaries/Commits /// ``` @@ -469,7 +469,7 @@ impl GlobalVars { /// /// # Examples /// - /// ``` + /// ```ignore /// use rusty_commit_saver::config::GlobalVars; /// /// let global_vars = GlobalVars::new(); @@ -486,7 +486,7 @@ impl GlobalVars { /// # Configuration Source /// /// Read from INI file: - /// ``` + /// ```text /// [templates] /// commit_date_path = %Y/%m-%B/%F.md /// ``` @@ -524,7 +524,7 @@ impl GlobalVars { /// /// # Examples /// - /// ``` + /// ```ignore /// use rusty_commit_saver::config::GlobalVars; /// /// let global_vars = GlobalVars::new(); @@ -541,7 +541,7 @@ impl GlobalVars { /// # Diary Table Usage /// /// In the diary table, this format appears in the TIME column: - /// ``` + /// ```text /// | FOLDER | TIME | COMMIT MESSAGE | REPOSITORY URL | BRANCH | COMMIT HASH | /// |--------|------|----------------|----------------|--------|-------------| /// | /work/project | 14:30:45 | feat: add feature | https://github.com/... | main | abc123... | @@ -550,7 +550,7 @@ impl GlobalVars { /// # Configuration Source /// /// Read from INI file: - /// ``` + /// ```text /// [templates] /// commit_datetime = %Y-%m-%d %H:%M:%S /// ``` @@ -651,7 +651,7 @@ impl GlobalVars { /// /// # Expected INI Key /// - /// ``` + /// ```text /// [templates] /// commit_datetime = %Y-%m-%d %H:%M:%S /// ``` @@ -683,7 +683,7 @@ impl GlobalVars { /// /// # Expected INI Key /// - /// ``` + /// ```text /// [templates] /// commit_date_path = %Y/%m-%B/%F.md /// ``` @@ -723,7 +723,7 @@ impl GlobalVars { /// /// # Expected INI Key /// - /// ``` + /// ```text /// [obsidian] /// commit_path = ~/Documents/Obsidian/Diaries/Commits /// ``` @@ -784,7 +784,7 @@ impl GlobalVars { /// /// # Expected INI Key /// - /// ``` + /// ```text /// [obsidian] /// root_path_dir = ~/Documents/Obsidian /// ``` @@ -834,7 +834,7 @@ impl GlobalVars { /// /// # Examples /// -/// ``` +/// ```text /// # Use default config (~/.config/rusty-commit-saver/rusty-commit-saver.ini) /// rusty-commit-saver /// @@ -858,7 +858,7 @@ pub struct UserInput { /// /// # CLI Usage /// - /// ``` + /// ```text /// rusty-commit-saver --config-ini /custom/path/config.ini /// ``` /// @@ -888,7 +888,7 @@ pub struct UserInput { /// /// # CLI Usage /// -/// ``` +/// ```text /// # Use default config /// rusty-commit-saver /// # Returns: /home/user/.config/rusty-commit-saver/rusty-commit-saver.ini @@ -900,7 +900,7 @@ pub struct UserInput { /// /// # Examples /// -/// ``` +/// ```ignore /// use rusty_commit_saver::config::retrieve_config_file_path; /// /// let config_path = retrieve_config_file_path(); @@ -950,7 +950,7 @@ pub fn retrieve_config_file_path() -> String { /// # See Also /// /// - [`get_default_ini_path()`] - Constructs the default configuration path -fn get_or_default_config_ini_path() -> String { +pub fn get_or_default_config_ini_path() -> String { info!("[get_or_default_config_ini_path()]: Parsing CLI inputs."); let args = UserInput::parse(); @@ -990,7 +990,7 @@ fn get_or_default_config_ini_path() -> String { /// /// # Directory Structure /// -/// ``` +/// ```text /// ~/.config/ /// └── rusty-commit-saver/ /// └── rusty-commit-saver.ini @@ -1003,7 +1003,7 @@ fn get_or_default_config_ini_path() -> String { /// /// # Examples /// -/// ``` +/// ```ignore /// // Internal usage /// let default_path = get_default_ini_path(); /// // Returns: "/home/user/.config/rusty-commit-saver/rusty-commit-saver.ini" @@ -1012,7 +1012,7 @@ fn get_or_default_config_ini_path() -> String { /// # See Also /// /// - [`retrieve_config_file_path()`] - Public API for getting config path -fn get_default_ini_path() -> String { +pub fn get_default_ini_path() -> String { info!("[get_default_ini_path()]: Getting default ini file."); let cfg_str = "~/.config/rusty-commit-saver/rusty-commit-saver.ini".to_string(); set_proper_home_dir(&cfg_str) @@ -1043,7 +1043,7 @@ fn get_default_ini_path() -> String { /// /// # Expected INI Structure /// -/// ``` +/// ```text /// [obsidian] /// root_path_dir = ~/Documents/Obsidian /// commit_path = Diaries/Commits @@ -1061,7 +1061,7 @@ fn get_default_ini_path() -> String { /// /// - [`retrieve_config_file_path()`] - Resolves the config file path /// - [`parse_ini_content()`] - Parses INI text into `Ini` struct -fn get_ini_file() -> Ini { +pub fn get_ini_file() -> Ini { info!("[get_ini_file()]: Retrieving the INI File"); let content_ini = retrieve_config_file_path(); let mut config = Ini::new(); @@ -1093,7 +1093,7 @@ fn get_ini_file() -> Ini { /// /// # Examples /// -/// ``` +/// ```ignore /// // On Linux/macOS with home at /home/user /// let expanded = set_proper_home_dir("~/Documents/Obsidian"); /// assert_eq!(expanded, "/home/user/Documents/Obsidian"); diff --git a/src/lib.rs b/src/lib.rs index 4033926..4b8db4f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,7 @@ //! //! ## Quick Start //! -//! ``` +//! ```ignore //! use rusty_commit_saver::{run_commit_saver, config::GlobalVars}; //! use std::path::PathBuf; //! @@ -39,7 +39,7 @@ //! //! Example configuration: //! -//! ``` +//! ```text //! [obsidian] //! root_path_dir = ~/Documents/Obsidian //! commit_path = Diaries/Commits diff --git a/src/main.rs b/src/main.rs index 2db17d0..bdaeb53 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,7 +49,7 @@ use std::path::PathBuf; /// /// # Examples /// -/// ``` +/// ```ignore /// use rusty_commit_saver::run_commit_saver; /// use std::path::PathBuf; /// @@ -65,7 +65,7 @@ use std::path::PathBuf; /// /// # Workflow /// -/// ``` +/// ```text /// ┌─────────────────────────────────┐ /// │ Discover Git commit metadata │ /// └────────────┬────────────────────┘ diff --git a/src/vim_commit.rs b/src/vim_commit.rs index 608c30a..f3cab4d 100644 --- a/src/vim_commit.rs +++ b/src/vim_commit.rs @@ -23,7 +23,7 @@ use log::warn; /// /// # Examples /// -/// ``` +/// ```ignore /// use rusty_commit_saver::CommitSaver; /// /// // Automatically populated from current Git repository @@ -82,7 +82,7 @@ pub struct CommitSaver { /// /// # Examples /// - /// ``` + /// ```text /// Original: "feat: add feature\n\nWith details" /// Formatted: "feat: add feature
With details" /// @@ -129,7 +129,7 @@ pub struct CommitSaver { /// /// # Examples /// -/// ``` +/// ```ignore /// use rusty_commit_saver::CommitSaver; /// /// // Using Default trait directly @@ -184,7 +184,7 @@ impl CommitSaver { /// /// # Examples /// - /// ``` + /// ```ignore /// use rusty_commit_saver::CommitSaver; /// /// let saver = CommitSaver::new(); @@ -216,7 +216,7 @@ impl CommitSaver { /// /// # Format /// - /// ``` + /// ```text /// | /path/to/repo | 14:30:45 | feat: add feature | https://github.com/user/repo.git | main | abc123... | /// ``` /// @@ -255,7 +255,7 @@ impl CommitSaver { /// /// # Examples /// - /// ``` + /// ```ignore /// use rusty_commit_saver::CommitSaver; /// use chrono::{TimeZone, Utc}; /// @@ -310,7 +310,7 @@ impl CommitSaver { /// /// # Examples /// - /// ``` + /// ```ignore /// use rusty_commit_saver::CommitSaver; /// use std::path::PathBuf; /// use chrono::{TimeZone, Utc}; @@ -381,7 +381,7 @@ impl CommitSaver { /// /// # Examples /// - /// ``` + /// ```text /// // With format "%Y/%m-%B/%F.md" and datetime 2025-01-14: /// // Returns: "2025/01-January/2025-01-14.md" /// @@ -424,7 +424,7 @@ impl CommitSaver { /// /// # Examples /// - /// ``` + /// ```ignore /// use rusty_commit_saver::CommitSaver; /// use std::path::PathBuf; /// @@ -506,7 +506,7 @@ tags:\n" /// /// # Examples /// -/// ``` +/// ```ignore /// use rusty_commit_saver::vim_commit::get_parent_from_full_path; /// use std::path::{Path, PathBuf}; /// @@ -556,7 +556,7 @@ pub fn get_parent_from_full_path(full_diary_path: &Path) -> Result<&Path, Box Result<(), Box