From f63a80e0a56453e38492864e91a6f1830551e886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Tue, 8 Mar 2022 22:01:34 +0100 Subject: [PATCH 01/21] Add mlua as dependency --- Cargo.lock | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 99 insertions(+) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..116d802 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,98 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "memchr", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "git-bump" +version = "0.1.0-SNAPSHOT" +dependencies = [ + "mlua", +] + +[[package]] +name = "lua-src" +version = "544.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7341ba039a781c4982ca20761c55f44e07bfefd496a45b1e929763d88f5fc68b" +dependencies = [ + "cc", +] + +[[package]] +name = "luajit-src" +version = "210.3.2+resty1085a4d" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e27456f513225a9edd22fc0a5f526323f6adb3099c4de87a84ceb842d93ba4" +dependencies = [ + "cc", +] + +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "mlua" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29e2194305aa8301d5da9c1c98640047f4219f6b95c190f6860338ab9872b686" +dependencies = [ + "bstr", + "cc", + "lua-src", + "luajit-src", + "num-traits", + "once_cell", + "pkg-config", + "rustc-hash", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" + +[[package]] +name = "pkg-config" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" diff --git a/Cargo.toml b/Cargo.toml index d76798d..5bddbba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,4 @@ readme = "README.md" license = "MIT" [dependencies] +mlua = { version = "0.7", features = ["lua54", "vendored"] } From d67592ba66f4ade053e34fb28c69697a7cdd989e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Tue, 8 Mar 2022 23:06:29 +0100 Subject: [PATCH 02/21] Add first prototype This prototype is able to load a `bump.lua`, which is expected to contain a mapping table with filenames as keys and functions as values. These functions are expected to return the new contents of the files. --- src/main.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index e7a11a9..b4a5442 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,27 @@ -fn main() { - println!("Hello, world!"); +use std::collections::HashMap; +use std::env::args; +use std::fs; + +use mlua::prelude::*; +use mlua::Function; + +fn main() -> LuaResult<()> { + let version = args().nth(1).unwrap(); + + let lua = Lua::new(); + + let map = lua + .load(&fs::read_to_string("bump.lua").unwrap()) + .eval::>()?; + + for (file, f) in map { + let mut contents = f.call::<_, String>(version.clone())?; + if !contents.ends_with('\n') { + contents.push('\n') + } + + fs::write(file, contents).unwrap(); + } + + Ok(()) } From bdc1fd2be308905d8cf8a8031a4007aa06068ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Thu, 17 Mar 2022 23:25:00 +0100 Subject: [PATCH 03/21] Add dependency home --- Cargo.lock | 32 ++++++++++++++++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 33 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 116d802..8449477 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,9 +27,19 @@ checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" name = "git-bump" version = "0.1.0-SNAPSHOT" dependencies = [ + "home", "mlua", ] +[[package]] +name = "home" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654" +dependencies = [ + "winapi", +] + [[package]] name = "lua-src" version = "544.0.0" @@ -96,3 +106,25 @@ name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 5bddbba..6bbd89d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,5 @@ readme = "README.md" license = "MIT" [dependencies] +home = "0.5.3" mlua = { version = "0.7", features = ["lua54", "vendored"] } From aef66fd0068283f3c76204c3faf8ee4e74a03cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Thu, 17 Mar 2022 23:25:30 +0100 Subject: [PATCH 04/21] Add dependency git2 --- Cargo.lock | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 196 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 8449477..53b64d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,6 +8,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bstr" version = "0.2.17" @@ -22,15 +28,50 @@ name = "cc" version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] [[package]] name = "git-bump" version = "0.1.0-SNAPSHOT" dependencies = [ + "git2", "home", "mlua", ] +[[package]] +name = "git2" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3826a6e0e2215d7a41c2bfc7c9244123969273f3476b939a226aac0ab56e9e3c" +dependencies = [ + "bitflags", + "libc", + "libgit2-sys", + "log", + "openssl-probe", + "openssl-sys", + "url", +] + [[package]] name = "home" version = "0.5.3" @@ -40,6 +81,81 @@ dependencies = [ "winapi", ] +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "jobserver" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +dependencies = [ + "libc", +] + +[[package]] +name = "libc" +version = "0.2.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad5c14e80759d0939d013e6ca49930e59fc53dd8e5009132f76240c179380c09" + +[[package]] +name = "libgit2-sys" +version = "0.13.2+1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a42de9a51a5c12e00fc0e4ca6bc2ea43582fc6418488e8f615e905d886f258b" +dependencies = [ + "cc", + "libc", + "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +] + +[[package]] +name = "libssh2-sys" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libz-sys" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f35facd4a5673cb5a48822be2be1d4236c1c99cb4113cab7061ac720d5bf859" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + [[package]] name = "lua-src" version = "544.0.0" @@ -58,6 +174,12 @@ dependencies = [ "cc", ] +[[package]] +name = "matches" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" + [[package]] name = "memchr" version = "2.4.1" @@ -95,6 +217,31 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + [[package]] name = "pkg-config" version = "0.3.24" @@ -107,6 +254,54 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "tinyvec" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "unicode-bidi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 6bbd89d..7006a33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,5 +11,6 @@ readme = "README.md" license = "MIT" [dependencies] +git2 = "0.14.2" home = "0.5.3" mlua = { version = "0.7", features = ["lua54", "vendored"] } From 9b8ea1d24bc3a7320c6ca2eebacb1dc2f070eb50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Thu, 17 Mar 2022 23:29:57 +0100 Subject: [PATCH 05/21] Search bump config in multiple locations The bump config files will be searched in the following locations: - $HOME/.git-bump.lua Per-user global config file. - $GIT_DIR/git-bump.lua Per-repository config file, not intended for sharing. - $GIT_WORK_TREE/.git-bump.lua Per-repository config file, checked into Git for sharing. Those locations will be evaluated in order, a later file overrides mappings of the previous ones if they have matching keys. Missing config files will be silently ignored unless all files are missing, which results in a panic, since `git bump` needs at least one config file to do something. Also, this commit makes the file mappings relative to the $GIT_WORK_TREE, so that `git bump` can be called from anywhere in the repository and it will always modify the correct files. --- src/main.rs | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index b4a5442..525a66d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,13 +6,45 @@ use mlua::prelude::*; use mlua::Function; fn main() -> LuaResult<()> { + let repository = git2::Repository::discover(".").expect("Not a Git repository"); + + let workdir = match repository.workdir() { + Some(workdir) => workdir, + None => panic!("git-bump is not supported on bare repositories"), + }; + + let bump_configs = { + let config_user = + home::home_dir().and_then(|p| p.join(".git-bump.lua").canonicalize().ok()); + let config_repo_unshared = repository.path().join("git-bump.lua").canonicalize().ok(); + let config_repo_shared = workdir.join(".git-bump.lua").canonicalize().ok(); + + [config_user, config_repo_unshared, config_repo_shared] + .into_iter() + .flatten() + .collect::>() + }; + + if bump_configs.is_empty() { + panic!("No valid config files found") + } + let version = args().nth(1).unwrap(); let lua = Lua::new(); - let map = lua - .load(&fs::read_to_string("bump.lua").unwrap()) - .eval::>()?; + let mut map = HashMap::new(); + for config in bump_configs { + let content = fs::read_to_string(config); + let chunk = match content { + Ok(content) => lua.load(&content).eval::>(), + Err(_) => continue, + }; + + for (file, func) in chunk? { + map.insert(file, func); + } + } for (file, f) in map { let mut contents = f.call::<_, String>(version.clone())?; @@ -20,7 +52,7 @@ fn main() -> LuaResult<()> { contents.push('\n') } - fs::write(file, contents).unwrap(); + fs::write(workdir.join(file), contents).unwrap(); } Ok(()) From c4edc0b7f69617d104642fa4301e094baacf94c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Fri, 18 Mar 2022 11:20:50 +0100 Subject: [PATCH 06/21] Split code into main and lib --- src/lib.rs | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 58 +++------------------------------------------------- 2 files changed, 62 insertions(+), 55 deletions(-) create mode 100644 src/lib.rs diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..6e5b926 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,59 @@ +use std::collections::HashMap; +use std::env::args; +use std::fs; + +use mlua::prelude::*; +use mlua::Function; + +pub fn bump() -> LuaResult<()> { + let repository = git2::Repository::discover(".").expect("Not a Git repository"); + + let workdir = match repository.workdir() { + Some(workdir) => workdir, + None => panic!("git-bump is not supported on bare repositories"), + }; + + let bump_configs = { + let config_user = + home::home_dir().and_then(|p| p.join(".git-bump.lua").canonicalize().ok()); + let config_repo_unshared = repository.path().join("git-bump.lua").canonicalize().ok(); + let config_repo_shared = workdir.join(".git-bump.lua").canonicalize().ok(); + + [config_user, config_repo_unshared, config_repo_shared] + .into_iter() + .flatten() + .collect::>() + }; + + if bump_configs.is_empty() { + panic!("No valid config files found") + } + + let version = args().nth(1).unwrap(); + + let lua = Lua::new(); + + let mut map = HashMap::new(); + for config in bump_configs { + let content = fs::read_to_string(config); + let chunk = match content { + Ok(content) => lua.load(&content).eval::>(), + Err(_) => continue, + }; + + for (file, func) in chunk? { + map.insert(file, func); + } + } + + for (file, f) in map { + let mut contents = f.call::<_, String>(version.clone())?; + if !contents.ends_with('\n') { + contents.push('\n') + } + + fs::write(workdir.join(file), contents).unwrap(); + } + + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index 525a66d..a481b1b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,59 +1,7 @@ -use std::collections::HashMap; -use std::env::args; -use std::fs; - use mlua::prelude::*; -use mlua::Function; - -fn main() -> LuaResult<()> { - let repository = git2::Repository::discover(".").expect("Not a Git repository"); - - let workdir = match repository.workdir() { - Some(workdir) => workdir, - None => panic!("git-bump is not supported on bare repositories"), - }; - - let bump_configs = { - let config_user = - home::home_dir().and_then(|p| p.join(".git-bump.lua").canonicalize().ok()); - let config_repo_unshared = repository.path().join("git-bump.lua").canonicalize().ok(); - let config_repo_shared = workdir.join(".git-bump.lua").canonicalize().ok(); - - [config_user, config_repo_unshared, config_repo_shared] - .into_iter() - .flatten() - .collect::>() - }; - - if bump_configs.is_empty() { - panic!("No valid config files found") - } - let version = args().nth(1).unwrap(); +use git_bump::bump; - let lua = Lua::new(); - - let mut map = HashMap::new(); - for config in bump_configs { - let content = fs::read_to_string(config); - let chunk = match content { - Ok(content) => lua.load(&content).eval::>(), - Err(_) => continue, - }; - - for (file, func) in chunk? { - map.insert(file, func); - } - } - - for (file, f) in map { - let mut contents = f.call::<_, String>(version.clone())?; - if !contents.ends_with('\n') { - contents.push('\n') - } - - fs::write(workdir.join(file), contents).unwrap(); - } - - Ok(()) +fn main() -> LuaResult<()> { + bump() } From a8c1880c9194a9ec60aa2acbf9f44353616d55f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 19 Mar 2022 19:26:31 +0100 Subject: [PATCH 07/21] Add dependency thiserror --- Cargo.lock | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 57 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 53b64d5..ab88ec4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,6 +55,7 @@ dependencies = [ "git2", "home", "mlua", + "thiserror", ] [[package]] @@ -248,12 +249,61 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" +[[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4af2ec4714533fcdf07e886f17025ace8b997b9ce51204ee69b6da831c3da57" +dependencies = [ + "proc-macro2", +] + [[package]] name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "syn" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "thiserror" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tinyvec" version = "1.5.1" @@ -284,6 +334,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + [[package]] name = "url" version = "2.2.2" diff --git a/Cargo.toml b/Cargo.toml index 7006a33..c76a724 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,3 +14,4 @@ license = "MIT" git2 = "0.14.2" home = "0.5.3" mlua = { version = "0.7", features = ["lua54", "vendored"] } +thiserror = "1.0.30" From 59146387922caeb868a6f1d97fac60e210e6efee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 19 Mar 2022 19:27:14 +0100 Subject: [PATCH 08/21] Add custom error module --- src/error.rs | 24 ++++++++++++++++++++++++ src/lib.rs | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 src/error.rs diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..ab2e023 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,24 @@ +pub type Result = std::result::Result; + +#[derive(Debug, thiserror::Error)] +#[non_exhaustive] +pub enum Error { + #[error("No version given")] + NoVersionGiven, + #[error("Not a Git repository")] + NotARepository, + #[error("Not supported on bare repositories")] + BareRepositoryNotSupported, + #[error("No valid config files found")] + NoValidConfigFound, + #[error("Failed to load Lua code: {source}")] + LuaLoadingFailed { source: mlua::Error }, + #[error("Failed to execute Lua code: {source}")] + LuaExecutionFailed { source: mlua::Error }, + #[error(transparent)] + LuaError(#[from] mlua::Error), + #[error("Failed to write to file: {source}")] + WriteFailed { source: std::io::Error }, + #[error(transparent)] + IoError(#[from] std::io::Error), +} diff --git a/src/lib.rs b/src/lib.rs index 6e5b926..f39d780 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,8 @@ use std::fs; use mlua::prelude::*; use mlua::Function; +mod error; + pub fn bump() -> LuaResult<()> { let repository = git2::Repository::discover(".").expect("Not a Git repository"); From 030a11def2aaba59acd9496b0da5a51d49fae3bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 19 Mar 2022 19:28:20 +0100 Subject: [PATCH 09/21] Use custom errors instead of panics --- src/lib.rs | 28 ++++++++++++++++------------ src/main.rs | 9 +++++---- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f39d780..04777b6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,15 +5,16 @@ use std::fs; use mlua::prelude::*; use mlua::Function; +pub use crate::{error::Error, error::Result}; + mod error; -pub fn bump() -> LuaResult<()> { - let repository = git2::Repository::discover(".").expect("Not a Git repository"); +pub fn bump() -> Result<()> { + let repository = git2::Repository::discover(".").map_err(|_| Error::NotARepository)?; - let workdir = match repository.workdir() { - Some(workdir) => workdir, - None => panic!("git-bump is not supported on bare repositories"), - }; + let workdir = repository + .workdir() + .ok_or_else(|| Error::BareRepositoryNotSupported)?; let bump_configs = { let config_user = @@ -28,10 +29,10 @@ pub fn bump() -> LuaResult<()> { }; if bump_configs.is_empty() { - panic!("No valid config files found") + return Err(Error::NoValidConfigFound); } - let version = args().nth(1).unwrap(); + let version = args().nth(1).ok_or(Error::NoVersionGiven)?; let lua = Lua::new(); @@ -41,20 +42,23 @@ pub fn bump() -> LuaResult<()> { let chunk = match content { Ok(content) => lua.load(&content).eval::>(), Err(_) => continue, - }; + } + .map_err(|source| Error::LuaLoadingFailed { source })?; - for (file, func) in chunk? { + for (file, func) in chunk { map.insert(file, func); } } for (file, f) in map { - let mut contents = f.call::<_, String>(version.clone())?; + let mut contents = f + .call::<_, String>(version.clone()) + .map_err(|source| Error::LuaExecutionFailed { source })?; if !contents.ends_with('\n') { contents.push('\n') } - fs::write(workdir.join(file), contents).unwrap(); + fs::write(workdir.join(file), contents).map_err(|source| Error::WriteFailed { source })?; } Ok(()) diff --git a/src/main.rs b/src/main.rs index a481b1b..e77b3b6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,8 @@ -use mlua::prelude::*; - use git_bump::bump; -fn main() -> LuaResult<()> { - bump() +fn main() { + if let Err(err) = bump() { + eprintln!("Error: {}", err); + std::process::exit(1); + } } From c9f22ed8ddded33c3593a79b0f83e9a2716099d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 19 Mar 2022 20:35:27 +0100 Subject: [PATCH 10/21] Only operate on existing files --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 04777b6..91df61b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,6 +51,12 @@ pub fn bump() -> Result<()> { } for (file, f) in map { + let file = workdir.join(file); + + if !file.exists() { + continue; + } + let mut contents = f .call::<_, String>(version.clone()) .map_err(|source| Error::LuaExecutionFailed { source })?; @@ -58,7 +64,7 @@ pub fn bump() -> Result<()> { contents.push('\n') } - fs::write(workdir.join(file), contents).map_err(|source| Error::WriteFailed { source })?; + fs::write(file, contents).map_err(|source| Error::WriteFailed { source })?; } Ok(()) From 8c4fa748dfbbdfa8ebc99f01cf73f04ab17ab66f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sun, 20 Mar 2022 09:25:13 +0100 Subject: [PATCH 11/21] Add error for failed reading --- src/error.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/error.rs b/src/error.rs index ab2e023..8233d63 100644 --- a/src/error.rs +++ b/src/error.rs @@ -17,6 +17,8 @@ pub enum Error { LuaExecutionFailed { source: mlua::Error }, #[error(transparent)] LuaError(#[from] mlua::Error), + #[error("Failed to read to file: {source}")] + ReadFailed { source: std::io::Error }, #[error("Failed to write to file: {source}")] WriteFailed { source: std::io::Error }, #[error(transparent)] From ba13de36f49ddbf9daad9dbc4114df5589e703f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sun, 20 Mar 2022 09:25:38 +0100 Subject: [PATCH 12/21] Pass file contents as second parameter This way the Lua function can directly alter the file contents if necessary, without reading it in by itself. --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 91df61b..684a6aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,8 +57,10 @@ pub fn bump() -> Result<()> { continue; } + let contents = fs::read_to_string(&file).map_err(|source| Error::ReadFailed { source })?; + let mut contents = f - .call::<_, String>(version.clone()) + .call::<_, String>((version.clone(), contents)) .map_err(|source| Error::LuaExecutionFailed { source })?; if !contents.ends_with('\n') { contents.push('\n') From c814a43ca05a1cad338606d992b08c88019830bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sun, 20 Mar 2022 16:25:23 +0100 Subject: [PATCH 13/21] Disable default features on Git Since we only need Git to find the root directory, do not enable default features. --- Cargo.lock | 37 ------------------------------------- Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab88ec4..1f9f587 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,8 +68,6 @@ dependencies = [ "libc", "libgit2-sys", "log", - "openssl-probe", - "openssl-sys", "url", ] @@ -116,26 +114,10 @@ checksum = "3a42de9a51a5c12e00fc0e4ca6bc2ea43582fc6418488e8f615e905d886f258b" dependencies = [ "cc", "libc", - "libssh2-sys", "libz-sys", - "openssl-sys", "pkg-config", ] -[[package]] -name = "libssh2-sys" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", -] - [[package]] name = "libz-sys" version = "1.1.5" @@ -218,25 +200,6 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "percent-encoding" version = "2.1.0" diff --git a/Cargo.toml b/Cargo.toml index c76a724..f19f6a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ readme = "README.md" license = "MIT" [dependencies] -git2 = "0.14.2" +git2 = { version = "0.14.2", default-features = false } home = "0.5.3" mlua = { version = "0.7", features = ["lua54", "vendored"] } thiserror = "1.0.30" From 2a5b968c77b031528891e5549b5ec7fcd5ca6bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 26 Mar 2022 00:30:39 +0100 Subject: [PATCH 14/21] Add sample bump config --- .git-bump.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .git-bump.lua diff --git a/.git-bump.lua b/.git-bump.lua new file mode 100644 index 0000000..f9df41b --- /dev/null +++ b/.git-bump.lua @@ -0,0 +1,44 @@ +return { + ["CHANGES.md"] = function(version, content) + -- either replace the first line with the concrete release number or + -- add an "upcoming" line, depending on the given version string + + local current_first_line = content:match("^([^\n]*)\n") or "" + local current_version = current_first_line:match("%d+%.%d+%.%d+") + local pure_version = version:match("%d+%.%d+%.%d+") + + local format_string + if current_version == nil or current_version == pure_version then + -- if the current version is an upcoming version, or if both pure + -- versions are the same, replace the first line + format_string = "%s\n%s" + content = content:gsub("^[^\n]*\n", "", 1) + else + -- otherwise, prepend a new line + format_string = "%s\n\n%s" + end + + local first_line + if version:find("%-SNAPSHOT$") then + -- if the new version is a snapshot, use an "upcoming" header + first_line = "# Changes since latest release" + else + -- otherwise use the concrete version + first_line = "# Changes in " .. version + end + + return (format_string):format(first_line, content) + end, + + ["Cargo.toml"] = function(version, content) + -- replace the first "version" attribute, which is most likely our + -- own, with the current version string + return content:gsub( + 'version = %b""', ('version = "%s"'):format(version), 1 + ) + end, + + VERSION = function(version) + return version + end +} From e03b05185c724ea5d7dbd24e5050b67870ab853c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 26 Mar 2022 00:31:04 +0100 Subject: [PATCH 15/21] Add LuaFormatter config --- .lua-format | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .lua-format diff --git a/.lua-format b/.lua-format new file mode 100644 index 0000000..2995815 --- /dev/null +++ b/.lua-format @@ -0,0 +1,32 @@ +column_limit: 78 +indent_width: 4 +use_tab: false +tab_width: 4 +continuation_indent_width: 4 +spaces_before_call: 1 +keep_simple_control_block_one_line: false +keep_simple_function_one_line: false +align_args: true +break_after_functioncall_lp: true +break_before_functioncall_rp: true +spaces_inside_functioncall_parens: false +spaces_inside_functiondef_parens: false +align_parameter: true +chop_down_parameter: true +break_after_functiondef_lp: true +break_before_functiondef_rp: true +align_table_field: true +break_after_table_lb: true +break_before_table_rb: true +chop_down_table: true +chop_down_kv_table: true +table_sep: "," +extra_sep_at_table_end: false +column_table_limit: 78 +spaces_inside_table_braces: false +break_after_operator: true +double_quote_to_single_quote: false +single_quote_to_double_quote: false +spaces_around_equals_in_field: true +line_breaks_after_function_body: 1 +line_separator: input From 33fbb2e3bb21ea17cb281539aa4bc4d61566187f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 26 Mar 2022 00:31:40 +0100 Subject: [PATCH 16/21] Add README --- README.md | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..79c5f10 --- /dev/null +++ b/README.md @@ -0,0 +1,128 @@ +# git-bump + +Consistently bump your version numbers with Lua scripts. + +## Motivation + +When publishing a new software release, there are usually a couple of places +where you want to update the current version number: + +- configuration files like `Cargo.toml` and `package.json` +- source files with defined constants for your application +- a conventional `VERSION` file in your repository root +- your changelog +- maybe a lot of other places, depending on you specific needs and workflow + +Also, depending on your workflow, you might want to first bump your version to +something like `1.2.3-RC`, then after some final testing `1.2.3` and +eventually to a development version `1.3.0-SNAPSHOT`. + +Since these tasks can be nicely automated, you might want to have a small +script that does the bumping for you. I even ended up with a `bump.sh` in each +of my projects, which are all quite similar, especially the ones for the same +programming language. To avoid this kind of boilerplate code in every single +repository, I came up with `git-bump` which is configurable via Lua scripts. + +`git-bump` searches for configuration files in certain +[locations](#configuration-file-locations), aggregates them, and calls a +custom Lua function for every defined file. This way it is possible to define +global version bump functions that can be used in each repository. + +## Installation + +`git-bump` can be installed easily through Cargo via `crates.io`: + +```shell script +cargo install git-bump +``` + +## Usage + +To bump your versions to `1.2.3`, it is as simple as: + +```shell script +git-bump 1.2.3 +``` + +Or, with Git subcommand syntax: + +```shell script +git bump 1.2.3 +``` + +Well, maybe not quite that easy. If you do not have any configuration files +yet, then you will be presented with an error: + +```text +$ git bump 1.2.3 +Error: No valid config files found +``` + +For a first success, let's start with a very simple configuration file in the +root of your Git repository. Name it `.git-bump.lua` (the leading `.` denotes +a hidden file in Linux and is quite usual for such configuration files) with +the following contents: + +```lua +return { + VERSION = function(version) + return version + end, +} +``` + +The configuration files are expected to return a Lua table. The keys are the +file names you want to run the bumper on, relative to the Git repository root. +The value is a Lua function, taking two parameters: The version that was given +as argument to `git-bump` and the contents of the file for conveniently +altering. If you do not need the current file content, you can ignore the +second parameter, Lua does not care about extraneous parameters. The functions +need to return the new contents of the file, which will then be written into +the according files. + +In this example, the file `VERSION` will only contain the given version string. + +More complex examples can be found in the section [Sample +Functions](#sample-functions). + +Since such configurations could be shared across multiple, different +repositories, `git-bump` will not create new files, but only operate on +existing files. So, for this example, create `VERSION` and run the bumper +again: + +```text +$ touch VERSION +$ git bump 1.2.3 +$ cat VERSION +1.2.3 +``` + +## Configuration File Locations + +The bump config files will be searched in the following locations: + +- `$HOME/.git-bump.lua` (Unix) or `%USERPROFILE%\.git-bump.lua` (Windows) + + Per-user global config file. + +- `$GIT_DIR/git-bump.lua` + + Per-repository config file, not intended for sharing. + +- `$GIT_WORK_TREE/.git-bump.lua` + + Per-repository config file, may be checked into Git for sharing. + +Those locations will be evaluated in order, a later file overrides mappings of +the previous ones if they have matching keys. Missing config files will be +silently ignored. However, all files missing results in an error, since +`git-bump` needs at least one config file to do something. + +## Sample Functions + +Find the latest sample config file here: +https://github.com/FloGa/git-bump/blob/develop/.git-bump.lua + +This is a non-exhaustive list of possible functions that can be used in your +config files. If you have ideas for more default functions, don't hesitate to +open a PR! diff --git a/src/lib.rs b/src/lib.rs index 684a6aa..107cd85 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,132 @@ +//! # git-bump +//! +//! Consistently bump your version numbers with Lua scripts. +//! +//! ## Motivation +//! +//! When publishing a new software release, there are usually a couple of places +//! where you want to update the current version number: +//! +//! - configuration files like `Cargo.toml` and `package.json` +//! - source files with defined constants for your application +//! - a conventional `VERSION` file in your repository root +//! - your changelog +//! - maybe a lot of other places, depending on you specific needs and workflow +//! +//! Also, depending on your workflow, you might want to first bump your version to +//! something like `1.2.3-RC`, then after some final testing `1.2.3` and +//! eventually to a development version `1.3.0-SNAPSHOT`. +//! +//! Since these tasks can be nicely automated, you might want to have a small +//! script that does the bumping for you. I even ended up with a `bump.sh` in each +//! of my projects, which are all quite similar, especially the ones for the same +//! programming language. To avoid this kind of boilerplate code in every single +//! repository, I came up with `git-bump` which is configurable via Lua scripts. +//! +//! `git-bump` searches for configuration files in certain +//! [locations](#configuration-file-locations), aggregates them, and calls a +//! custom Lua function for every defined file. This way it is possible to define +//! global version bump functions that can be used in each repository. +//! +//! ## Installation +//! +//! `git-bump` can be installed easily through Cargo via `crates.io`: +//! +//! ```shell script +//! cargo install git-bump +//! ``` +//! +//! ## Usage +//! +//! To bump your versions to `1.2.3`, it is as simple as: +//! +//! ```shell script +//! git-bump 1.2.3 +//! ``` +//! +//! Or, with Git subcommand syntax: +//! +//! ```shell script +//! git bump 1.2.3 +//! ``` +//! +//! Well, maybe not quite that easy. If you do not have any configuration files +//! yet, then you will be presented with an error: +//! +//! ```text +//! $ git bump 1.2.3 +//! Error: No valid config files found +//! ``` +//! +//! For a first success, let's start with a very simple configuration file in the +//! root of your Git repository. Name it `.git-bump.lua` (the leading `.` denotes +//! a hidden file in Linux and is quite usual for such configuration files) with +//! the following contents: +//! +//! ```lua +//! return { +//! VERSION = function(version) +//! return version +//! end, +//! } +//! ``` +//! +//! The configuration files are expected to return a Lua table. The keys are the +//! file names you want to run the bumper on, relative to the Git repository root. +//! The value is a Lua function, taking two parameters: The version that was given +//! as argument to `git-bump` and the contents of the file for conveniently +//! altering. If you do not need the current file content, you can ignore the +//! second parameter, Lua does not care about extraneous parameters. The functions +//! need to return the new contents of the file, which will then be written into +//! the according files. +//! +//! In this example, the file `VERSION` will only contain the given version string. +//! +//! More complex examples can be found in the section [Sample +//! Functions](#sample-functions). +//! +//! Since such configurations could be shared across multiple, different +//! repositories, `git-bump` will not create new files, but only operate on +//! existing files. So, for this example, create `VERSION` and run the bumper +//! again: +//! +//! ```text +//! $ touch VERSION +//! $ git bump 1.2.3 +//! $ cat VERSION +//! 1.2.3 +//! ``` +//! +//! ## Configuration File Locations +//! +//! The bump config files will be searched in the following locations: +//! +//! - `$HOME/.git-bump.lua` (Unix) or `%USERPROFILE%\.git-bump.lua` (Windows) +//! +//! Per-user global config file. +//! +//! - `$GIT_DIR/git-bump.lua` +//! +//! Per-repository config file, not intended for sharing. +//! +//! - `$GIT_WORK_TREE/.git-bump.lua` +//! +//! Per-repository config file, may be checked into Git for sharing. +//! +//! Those locations will be evaluated in order, a later file overrides mappings of +//! the previous ones if they have matching keys. Missing config files will be +//! silently ignored. However, all files missing results in an error, since +//! `git-bump` needs at least one config file to do something. +//! +//! ## Sample Functions +//! +//! Find the latest sample config file here: +//! https://github.com/FloGa/git-bump/blob/develop/.git-bump.lua +//! +//! This is a non-exhaustive list of possible functions that can be used in your +//! config files. If you have ideas for more default functions, don't hesitate to +//! open a PR! + use std::collections::HashMap; use std::env::args; use std::fs; @@ -29,7 +158,7 @@ pub fn bump() -> Result<()> { }; if bump_configs.is_empty() { - return Err(Error::NoValidConfigFound); + return Ok(()); } let version = args().nth(1).ok_or(Error::NoVersionGiven)?; From 53976b8ffd1b4953b563440bef822c6d93ef7208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 26 Mar 2022 00:39:34 +0100 Subject: [PATCH 17/21] Add MIT license file --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..acf6fec --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Florian Gamböck + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 077b83ae9dc1cda2bb1844a59e2c0aee8a29912d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 26 Mar 2022 00:50:29 +0100 Subject: [PATCH 18/21] Add meaningful categories --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f19f6a1..8c27ff8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" description = "Use Lua scripts to quickly bump versions in files." repository = "https://github.com/FloGa/git-bump" readme = "README.md" -#categories = [] +categories = ["cli", "git", "utility"] license = "MIT" [dependencies] From af4bc38741bd2f7e5f3911b60e2baa0fa588f248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 26 Mar 2022 00:41:23 +0100 Subject: [PATCH 19/21] Bump version to 0.1.0-RC --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f9f587..989b2e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,7 +50,7 @@ dependencies = [ [[package]] name = "git-bump" -version = "0.1.0-SNAPSHOT" +version = "0.1.0-RC" dependencies = [ "git2", "home", diff --git a/Cargo.toml b/Cargo.toml index 8c27ff8..6d68f15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "git-bump" -version = "0.1.0-SNAPSHOT" +version = "0.1.0-RC" authors = ["Florian Gamböck "] edition = "2021" From 77e71134df8ee48b337d0b6a457d6291ca570655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 26 Mar 2022 00:42:09 +0100 Subject: [PATCH 20/21] Add VERSION and Changelog --- CHANGES.md | 3 +++ VERSION | 1 + 2 files changed, 4 insertions(+) create mode 100644 CHANGES.md create mode 100644 VERSION diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..fbe5718 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,3 @@ +# Changes in 0.1.0-RC + +Initial release. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..c87e310 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0-RC From 5b9d8d86ce8e9c3acde9dfe51e79d4a2beac15d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sat, 26 Mar 2022 00:44:41 +0100 Subject: [PATCH 21/21] Bump version to 0.1.0 --- CHANGES.md | 2 +- Cargo.lock | 2 +- Cargo.toml | 2 +- VERSION | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fbe5718..6c87f12 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,3 @@ -# Changes in 0.1.0-RC +# Changes in 0.1.0 Initial release. diff --git a/Cargo.lock b/Cargo.lock index 989b2e8..d2014b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,7 +50,7 @@ dependencies = [ [[package]] name = "git-bump" -version = "0.1.0-RC" +version = "0.1.0" dependencies = [ "git2", "home", diff --git a/Cargo.toml b/Cargo.toml index 6d68f15..9ecf9ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "git-bump" -version = "0.1.0-RC" +version = "0.1.0" authors = ["Florian Gamböck "] edition = "2021" diff --git a/VERSION b/VERSION index c87e310..6e8bf73 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0-RC +0.1.0