Commit Graph

28 Commits

Author SHA1 Message Date
Martin Frost 4de268ee20 Use clap for git-mob 2021-12-11 00:54:35 +01:00
Martin Frost 68e8e93bd0 Use clap for git-delete-coauthor 2021-12-11 00:54:35 +01:00
Martin Frost 2a4bcd896e Use clap for git-edit-coauthor 2021-12-11 00:41:09 +01:00
Martin Frost 2009e9335a Use clap for git-add-coauthor 2021-12-11 00:41:09 +01:00
Martin Frost b0067e9115 Use clap for git-solo 2021-12-11 00:41:09 +01:00
Martin Frost 2b2cdd54e5 Add more docs to structopt definitions
This makes the generated documentation a tad more explanatory.
2021-12-10 23:49:22 +01:00
Martin Frost c9603845d5 Add structopt for git-solo
This means that we can run `git-solo --help` and get some information on
what that command is doing. This was missing before.
2021-12-10 23:48:46 +01: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 a97e37a9f3 Use &str instead of &String
We don't need a new object here, a slice is fine.
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 609cdf83d8 Add git-edit-coauthor command
It is now possible to edit the available co-authors, in case you
misspelled someone's name, or they change their email address, or
something.
2020-05-24 13:23:15 +02:00
Martin Frost 934405ad4b Tidy up write_coauthors_to_gitmessage_file
* Inline closure
* Do some actual error handling
2020-05-23 21:05:04 +02:00
Martin Frost e64c6d7b74 Tidy up git-solo 2020-05-23 21:04:51 +02:00
Martin Frost c69cc0a9bc git-delete-coauthor 2020-05-23 20:56:53 +02:00
Martin Frost 8e46759b0a git-add-coauthor 2020-05-23 20:56:53 +02:00
Martin Frost 7b65f8e7b7 Write selected co-authors to .git/.gitmessage 2020-05-23 20:56:32 +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
Martin Frost 8032a08656 Add working version of git-solo
`git-solo` clears the `.git/.gitmessage` commit message template in the
current git repository.

If the current working directory is not within a git repository, it will
print `Not in a git repository` on stderr and exit.
2020-05-23 20:56:32 +02:00