Skip to contents

A signature contains the author and timestamp of a commit. Each commit includes a signature of the author and committer (which can be identical).

Usage

git_signature_default(repo = ".")

git_signature(name, email, time = NULL)

git_signature_parse(sig)

Arguments

repo

The path to the git repository. If the directory is not a repository, parent directories are considered (see git_find). To disable this search, provide the filepath protected with I(). When using this parameter, always explicitly call by name (i.e. repo = ) because future versions of gert may have additional parameters.

name

Real name of the committer

email

Email address of the committer

time

timestamp of class POSIXt or NULL

sig

string in proper "First Last <[email protected]>" format, see details.

Details

A signature string has format "Real Name <email> timestamp tzoffset". The timestamp tzoffset piece can be omitted in which case the current local time is used. If not omitted, timestamp must contain the number of seconds since the Unix epoch and tzoffset is the timezone offset in hhmm format (note the lack of a colon separator)

Examples

# Your default user
try(git_signature_default())
#> Error in libgit2::git_repository_open_ext : 
#>   could not find repository from '/tmp/Rtmpav5wBS/gert/reference'

# Specify explicit name and email
git_signature("Some committer", "[email protected]")
#> [git signature]
#> Author: Some committer <[email protected]>
#> Date: Fri Jun 24 05:33:20 2022 +0000

# Create signature for an hour ago
(sig <- git_signature("Han", "[email protected]", Sys.time() - 3600))
#> [git signature]
#> Author: Han <[email protected]>
#> Date: Fri Jun 24 04:33:20 2022 +0000

# Parse a signature
git_signature_parse(sig)
#> $name
#> [1] "Han"
#> 
#> $email
#> [1] "[email protected]"
#> 
#> $time
#> [1] "2022-06-24 04:33:20 UTC"
#> 
#> $offset
#> [1] 0
#> 
git_signature_parse("Emma <[email protected]>")
#> $name
#> [1] "Emma"
#> 
#> $email
#> [1] "[email protected]"
#> 
#> $time
#> [1] "2022-06-24 05:33:20 UTC"
#> 
#> $offset
#> [1] 0
#>