Handle RAVC2_USER environment variable

This commit is contained in:
pancake 2021-07-26 17:00:36 +02:00
parent 67d43c4865
commit b552322004
2 changed files with 17 additions and 8 deletions

View File

@ -10,6 +10,8 @@ static void ravc2_show_help(void) {
" branch list all available branches\n" " branch list all available branches\n"
" commit [a] [m] [f] perform a commit with the added files\n" " commit [a] [m] [f] perform a commit with the added files\n"
" branch [name] change to another branch\n" " branch [name] change to another branch\n"
"Environment:\n"
" RAVC2_USER=[name] Override cfg.user value to author commit.\n"
"Examples:\n" "Examples:\n"
" ravc2 init\n" " ravc2 init\n"
" man ravc2\n"); " man ravc2\n");
@ -103,7 +105,11 @@ R_API int r_main_ravc2(int argc, const char **argv) {
return -10; return -10;
} }
} }
char *author = r_sys_whoami (); char *author = r_sys_getenv ("RAVC2_USER");
if (R_STR_ISEMPTY (author)) {
free (author);
author = r_sys_whoami ();
}
if (!author) { if (!author) {
free (message); free (message);
r_list_free (files); r_list_free (files);

View File

@ -1,11 +1,11 @@
.Dd Dec 28, 2020 .Dd Jul 26, 2021
.Dt RAVC2 1 .Dt RAVC2 1
.Sh NAME .Sh NAME
.Nm ravc2 .Nm ravc2
.Nd radare version control .Nd radare version control
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm ravc2 .Nm ravc2
.Op Fl ebBsSvxkKh .Op Fl hv
.Op [expr] ... .Op [expr] ...
.Sh DESCRIPTION .Sh DESCRIPTION
This command is part of the radare project. This command is part of the radare project.
@ -14,6 +14,7 @@ Implements a simple version control system that aims to work as frontend for git
.Pp .Pp
This command is pretty new and experimental. This command is pretty new and experimental.
.Sh OPTIONS .Sh OPTIONS
.Bl -tag -width Fl
.It Fl h .It Fl h
Show usage help message Show usage help message
.It Fl v .It Fl v
@ -22,12 +23,14 @@ Display version
.Sh USAGE .Sh USAGE
Available variable types are: Available variable types are:
.Pp .Pp
ravc2 init ravc2 init
echo hello world > README.md echo hello world > README.md
ravc2 add README.md ravc2 add README.md
ravc2 branch ravc2 branch
ravc2 commit ravc2 commit
.Pp .Pp
.Sh ENVIRONMENT
RAVC2_USER overrides cfg.user, which is based on r_sys_whoami() which is used to define the author for the VC commits.
.Sh SEE ALSO .Sh SEE ALSO
.Pp .Pp
.Xr radare2(1) .Xr radare2(1)