Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
FloGa committed Apr 3, 2022
2 parents 70476af + e174331 commit d45e194
Show file tree
Hide file tree
Showing 11 changed files with 655 additions and 90 deletions.
22 changes: 19 additions & 3 deletions .git-bump.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,25 @@ return {
["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
)

content = content:gsub(
'version = %b""', ('version = "%s"'):format(version), 1
)

local post_func = function()
-- run `cargo check` on the current package, which will then also
-- update Cargo.lock with the new version string

local pkgid
do
local process = io.popen("cargo pkgid")
pkgid = process:read("a")
process:close()
end
os.execute(("cargo check -p %q"):format(pkgid))
end

return content, {post_func = post_func}
end,

VERSION = function(version)
Expand Down
60 changes: 60 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
# Changes in 0.2.0

- Add two additional errors for hooks

- Support pre and post hook functions

Along with the new contents for a specified file, one can also define
hook functions that should be run *before* or *after* the new content is
written to the file.

The `pre_func` could be used, for example, to create a backup of the
file prior to updating it. The `post_func` might be used to do some
house keeping with modified config files.

The hooks must be returned as a Lua table with the members `pre_func`
and `post_func`. Both members are optional. If a hook function does not
exist, it will be silently ignored.

Example:

```lua
return {
VERSION = function(version)
local os = require("os")

local pre_func = function()
os.execute("cp VERSION VERSION.old")
end

local post_func = function()
os.execute("git commit -m 'Update VERSION' VERSION")
end

return version, {pre_func = pre_func, post_func = post_func}
end
}
```

- Add post_func example to git-bump.lua

This example will run `cargo check` after updating the version in
Cargo.toml. Not only will this validate the modified config, it will
also update Cargo.lock accordingly.

- Add function to print out sample config

- Create method for printing file paths

This list will include absolute file paths of all files that will be
considered when bumping versions.

- Adjust README regarding missing config files

Previously, the README mentioned that it is an error if no configuration
files exist. This was true in the very beginning, but after a few
practical tests I came to the conclusion that missing configuration
files should not cause an error, but just be silently ignored. This will
be better for automation scripts that might run on many repositories,
including those without any bump configurations.

# Changes in 0.1.0

Initial release.
174 changes: 161 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d45e194

Please sign in to comment.