Commit Graph

17 Commits

Author SHA1 Message Date
Martin Frost 3bb589e12c Extract clap args definitions to common cli module
Keeping these definitions separate from the implementations will help
generating man pages for the executables without putting _all_ of the
dependencies into the build-dependencies.
2023-04-07 23:21:33 +02:00
Martin Frost e932c00e85 Use error variables directly in the format! string 2023-02-13 21:37:33 +01:00
Martin Frost 8ec0cba227 Write absolute path to commit.template config var
This means that `git-mob` will work in git submodules.

Co-authored-by: Maria Hansson <mariahansson92@hotmail.com>
2022-05-13 18:26:16 +02:00
Martin Frost 9be6f97a5e Stop printing on stderr when adding first coauthor
Before this change, when running `git add-coauthor` without an existing
`~/.git-coauthors` file, the program would print an error message on
stderr that the file did not exist.

It would then create the file with the newly added co-author in it.

That message seemed unnecessary and so it has now been removed.

Co-authored-by: Maria Hansson <mariahansson92@hotmail.com>
2021-08-20 22:43:05 +02:00
Martin Frost fe1c91cfa5 Fix format 2021-08-18 23:20:02 +02:00
Martin Frost 9d09b31602 Fix needless-borrow 2021-08-18 23:20:02 +02:00
Martin Frost e60fae7031 v0.3.4 - Print correct main author
This change makes `get_main_author` try to fetch `user.name` and
`user.email` from the current repo before falling back to a global
default.

Co-authored-by: Maria Hansson <mariahansson92@hotmail.com>
2020-11-10 13:35:45 +01:00
Martin Frost 4575605991 v0.3.3 - Ensure commit.template is set
We currently ensure this by simply overriding any existing template.

This is of course sub-optimal, but the previous recommendation, to
globally set `commit.template` to a relative path would otherwise make
`git commit` crash when run in a repo without first creating that
template file, e.g. by running `git mob ...` or `git solo` in the
project directory before committing anything.

This way, we don't have to globally set `commit.template`, and git-mob
will still work.
2020-10-24 18:21:32 +02:00
Martin Frost 20997a0605 Rustfmt everything 2020-09-05 16:07:58 +02:00
Martin Frost 5f88d5a029 v0.3.0 - Override main author
This change allows the `-o <initials>` flag to override who the main
author of any commits in this repo will be going forward.

What this actually does, is that it modifies the Repository's config
file to change the `user.name` and `user.email` like this.

Running `git mob -o ae be` (given the corresponding authors have been
configured using `git add-coauthor`) is equivalent to doing:

    git config user.name "Alice Example"
    git config user.email "alice@example.com"
    git mob be # be being the initials of "Bob Example" <bob@example.com>
2020-06-19 13:38:04 +02:00
Martin Frost 15886667da Extract `with_git_repo_or_exit`
This function will come in handy when doing other actions with a git
repo, like when modifying a repository's config.
2020-06-19 13:23:56 +02:00
Martin Frost 747e19828c Wrap gitmessage template path in closure
Since the only thing the `repo` argument to `with_repo_or_exit` was used
for, was to extract the gitmessage template path from it, we can just do
that directly instead.
2020-05-24 13:48:51 +02:00
Martin Frost 8e46759b0a git-add-coauthor 2020-05-23 20:56:53 +02:00
Martin Frost ee7c56e0a0 Extract with_repo_or_exit
This will run a given function in a git repo, or print an error message
and exit if the current working directory is not within a git repo.
2020-05-23 20:56:32 +02:00
Martin Frost 41908686ed Extract gitmessage_template_file_path to lib
This piece of code will be used in a variety of places, so let's put it
somewhere where we can easily share it.
2020-05-23 20:56:32 +02:00
Martin Frost de5af01d1f First draft of git-mob binary
It can:

* Parse the `~/.git-coauthors` file
* List available co-authors with --list
* Filter available co-authors given a list of initials, giving an error
  if no co-author matches a given initial
2020-05-23 20:56:32 +02:00
Martin Frost 0061c5b112 Move get_main_author -> lib.rs 2020-05-23 20:56:32 +02:00