Skip to content

Commit

Permalink
Merge pull request #23 from jeffersonassilva/develop
Browse files Browse the repository at this point in the history
Show the email of author and other changes
  • Loading branch information
jeffersonassilva committed Jun 29, 2018
2 parents baa1384 + cb0dcee commit 27b2c6c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 35 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ Method | Descript
`branch([string $dir = null])` | Show the branch name | BOTH
`tag([string $dir = null])` | Show the tag name | BOTH
`revision([bool $long = false], [string $dir = null])` | Show the revision code | BOTH
`authorName([string $dir = null])` | Show the name of author | BOTH
`authorDate(string $format = 'Y-m-d H:i:s', [string $dir = null])` | Show the date of author | BOTH
`authorName([string $dir = null])` | Show the name of author | BOTH
`authorEmail([string $dir = null])` | Show the email of author | GIT
`committerDate(string $format = 'Y-m-d H:i:s', [string $dir = null])` | Show the date of committer | GIT
`committerName([string $dir = null])` | Show the name of committer | GIT
`committerEmail([string $dir = null])` | Show the email of committer | GIT
`committerDate(string $format = 'Y-m-d H:i:s', [string $dir = null])` | Show the date of committer | BOTH
`subject([string $dir = null])` | Show the subject commit | GIT

Author
Expand Down
71 changes: 38 additions & 33 deletions src/VcsPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@ public static function revision($long = false, $dir = null)
return current($revision);
}
/**
* Show the author date
* @param string $format Format of date, default is american format '%Y-%m-%d %H:%M:%S'
* @param string $dir Directory's path of project
* @return mixed
*/
public static function authorDate($format = 'Y-m-d H:i:s', $dir = null)
{
$authorDate = array();
$path = VcsPHP::documentRoot($dir);
if (VcsPHP::isGIT($dir)) {
$format = VcsPHP::formatDateToGit($format);
exec("cd $path && git log -1 --pretty='format:%ad' --date=format:'$format'", $authorDate);

} else if (VcsPHP::isSVN($dir)) {
exec("cd $path && svn info | grep 'Date' | awk '{print $4\" \"$5}'", $authorDate);
$authorDate = VcsPHP::formatDateToSvn($authorDate, $format);
}
return current($authorDate);
}
/**
* Show the name of author
* @param string $dir Directory's path of project
Expand All @@ -108,24 +129,29 @@ public static function authorName($dir = null)
}
/**
* Show the author date
* @param string $format Format of date, default is american format '%Y-%m-%d %H:%M:%S'
* Show the email of author
* @param string $dir Directory's path of project
* @return mixed
*/
public static function authorDate($format = 'Y-m-d H:i:s', $dir = null)
public static function authorEmail($dir = null)
{
$authorDate = array();
$path = VcsPHP::documentRoot($dir);
if (VcsPHP::isGIT($dir)) {
$format = VcsPHP::formatDateToGit($format);
exec("cd $path && git log -1 --pretty='format:%ad' --date=format:'$format'", $authorDate);
exec("cd $path && git log -1 --pretty='format:%ae'", $authorEmail);
return current($authorEmail);
}

} else if (VcsPHP::isSVN($dir)) {
exec("cd $path && svn info | grep 'Date' | awk '{print $4\" \"$5}'", $authorDate);
$authorDate = VcsPHP::formatDateToSvn($authorDate, $format);
}
return current($authorDate);
/**
* Show the date of committer
* @param string $format Optional format of date, default is american format '%Y-%m-%d %H:%M:%S'
* @param string $dir Directory's path of project
* @return mixed
*/
public static function committerDate($format = 'Y-m-d H:i:s', $dir = null)
{
$path = VcsPHP::documentRoot($dir);
$format = VcsPHP::formatDateToGit($format);
exec("cd $path && git log -1 --pretty='format:%cd' --date=format:'$format'", $committerDate);
return current($committerDate);
}

/**
Expand All @@ -152,27 +178,6 @@ public static function committerEmail($dir = null)
return current($committerEmail);
}

/**
* Show the date of committer
* @param string $format Optional format of date, default is american format '%Y-%m-%d %H:%M:%S'
* @param string $dir Directory's path of project
* @return mixed
*/
public static function committerDate($format = 'Y-m-d H:i:s', $dir = null)
{
$committerDate = array();
$path = VcsPHP::documentRoot($dir);
if (VcsPHP::isGIT($dir)) {
$format = VcsPHP::formatDateToGit($format);
exec("cd $path && git log -1 --pretty='format:%cd' --date=format:'$format'", $committerDate);

} else if (VcsPHP::isSVN($dir)) {
exec("cd $path && svn info | grep 'Date' | awk '{print $4\" \"$5}'", $committerDate);
$committerDate = VcsPHP::formatDateToSvn($committerDate, $format);
}
return current($committerDate);
}
/**
* Show the subject commit
* @param string $dir Directory's path of project
Expand Down

0 comments on commit 27b2c6c

Please sign in to comment.