Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace commitDate format to ISO8601 #176

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ $ ./gradlew test -PbuildJdkVersion=15 -PtestJavaVersion=8

```
myproject-foo.commitDate=2018-01-23 19\:14\:12 +0900
myproject-foo.commitISODate=2018-01-23T19:14:12+09:00
myproject-foo.repoStatus=dirty
myproject-foo.longCommitHash=2efe73d595a4687c9f8ad3d153ca8fe52604e20f
myproject-foo.shortCommitHash=2efe73d5
Expand Down
6 changes: 4 additions & 2 deletions lib/common-git.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private def getRepoStatus() {
version : project.version,
longCommitHash : '0000000000000000000000000000000000000000',
shortCommitHash : '0000000',
commitISODate : '1970-01-01T00:00:00+00:00',
commitDate : '1970-01-01 00:00:00 +0000',
repoStatus : 'unknown'
]
Expand All @@ -64,13 +65,14 @@ private def getRepoStatus() {

// Retrieve the repository status from the Git repository.
try {
def gitLogOut = project.ext.executeGit('log', '-1', '--format=format:%h%x20%H%x20%cd', '--date=iso', '--abbrev=9')
def gitLogOut = project.ext.executeGit('log', '-1', '--format=format:%h%x20%H%x20%cI%x20%ci', '--abbrev=9')
if (gitLogOut) {
logger.info("Latest commit: ${gitLogOut}")
def tokens = gitLogOut.tokenize(' ')
result.shortCommitHash = tokens[0]
result.longCommitHash = tokens[1]
result.commitDate = tokens[2..4].join(' ')
result.commitISODate = tokens[2]
result.commitDate = tokens[3..5].join(' ')
}

def gitStatusOut = project.ext.executeGit('status', '--porcelain')
Expand Down