Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a git commit author is valid

Tags:

git

bash

github

In a repository where I cant set both user.name and user.email configurations I need to script a commit with:

commit -a --message "message" --author="author"

Message and author are parametrized.

When I commit with a wrong author (not present on rev-list and bad formatted for git) I get:

fatal: --author 'bad-formatted-author' is not 'Name ' and matches no existing author

Is there any way to check against git if the author is valid before the commit?

like image 500
Giulio Caccin Avatar asked Mar 13 '23 10:03

Giulio Caccin


1 Answers

Use git commit -a --message "message" --author="author" --dry-run.

The added --dry-run flag will make git commit not actually commit anything but still exit non-zero if the --author option string given is invalid.

Note, however, that there may be other reasons the exit status is non-zero, such as the commit being empty (i.e. not having any changes).

like image 191
Raphael Schweikert Avatar answered Mar 15 '23 07:03

Raphael Schweikert