From 4e3824e5e39ef2142d6413d3349e226746d349d0 Mon Sep 17 00:00:00 2001 From: Georgi Pavlov Date: Wed, 10 Feb 2021 16:48:20 +0000 Subject: [PATCH] add web url to files git-data --- pkg/git/types.go | 1 + pkg/resourcehandlers/github/gitinfo.go | 3 +++ pkg/resourcehandlers/github/testdata/test_format_00_out.json | 1 + 3 files changed, 5 insertions(+) diff --git a/pkg/git/types.go b/pkg/git/types.go index 97a5effa..ce8eecbe 100644 --- a/pkg/git/types.go +++ b/pkg/git/types.go @@ -15,4 +15,5 @@ type GitInfo struct { PublishDate *string `json:"publishdate,omitempty"` Author *github.User `json:"author,omitempty"` Contributors []*github.User `json:"contributors,omitempty"` + WebURL *string `json:"weburl,omitempty"` } diff --git a/pkg/resourcehandlers/github/gitinfo.go b/pkg/resourcehandlers/github/gitinfo.go index bf9bd0da..25dfae68 100644 --- a/pkg/resourcehandlers/github/gitinfo.go +++ b/pkg/resourcehandlers/github/gitinfo.go @@ -36,6 +36,9 @@ func transform(commits []*github.RepositoryCommit) *git.GitInfo { lastModifiedDate := nonInternalCommits[0].GetCommit().GetCommitter().GetDate().Format(git.DateFormat) gitInfo.LastModifiedDate = &lastModifiedDate + webURL := nonInternalCommits[0].GetHTMLURL() + webURL = strings.Split(webURL, "/commit/")[0] + gitInfo.WebURL = &webURL publishDate := commits[len(nonInternalCommits)-1].GetCommit().GetCommitter().GetDate().Format(git.DateFormat) gitInfo.PublishDate = &publishDate diff --git a/pkg/resourcehandlers/github/testdata/test_format_00_out.json b/pkg/resourcehandlers/github/testdata/test_format_00_out.json index 71ecb454..f7b0a4b4 100644 --- a/pkg/resourcehandlers/github/testdata/test_format_00_out.json +++ b/pkg/resourcehandlers/github/testdata/test_format_00_out.json @@ -1,6 +1,7 @@ { "lastmod": "2020-06-18 18:40:47", "publishdate": "2020-06-18 15:07:40", + "weburl": "https://github.com/gardener/documentation", "author": { "login": "a-b", "id": 52317188,