From 15912ccc22759919d706aaed31f7787ff10e8df1 Mon Sep 17 00:00:00 2001 From: mohammad ali ashraf Date: Tue, 11 Apr 2023 06:05:14 +0500 Subject: [PATCH 1/2] issue #87 --- provider/github/provider.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/provider/github/provider.go b/provider/github/provider.go index 4d7d865..e5a12db 100644 --- a/provider/github/provider.go +++ b/provider/github/provider.go @@ -212,6 +212,11 @@ func (p Provider) getContent(repo *github.Repository) *domain.Content { c.ExtraData = append(c.ExtraData, author) } + if repo.UpdatedAt != nil { + lastUpdatedAt := "Updated on : " + repo.GetUpdatedAt().Format("2006-01-02") + c.ExtraData = append(c.ExtraData, lastUpdatedAt) + } + hs := p.Config.GetHashtags() hashtags := "" From 6347e516ce4f1058dae0ec346704f736d70012f7 Mon Sep 17 00:00:00 2001 From: mohammad ali ashraf Date: Sat, 13 May 2023 04:49:07 +0500 Subject: [PATCH 2/2] added test case for issue#87 --- provider/github/provider_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/provider/github/provider_test.go b/provider/github/provider_test.go index a4a5d9d..6e48653 100644 --- a/provider/github/provider_test.go +++ b/provider/github/provider_test.go @@ -228,6 +228,7 @@ func TestGetRepoUser(t *testing.T) { func TestGetContent(t *testing.T) { login, lang, url, name, desc := "t2", "g", "url", "repo", "desc" count := 1 + updatedAt, _ := time.Parse("2006-01-02", "2000-07-12") gu := github.User{Login: &login} for _, tc := range []struct { Name string @@ -267,6 +268,12 @@ func TestGetContent(t *testing.T) { repo: &github.Repository{Name: &name, Description: &desc, Language: &lang, HTMLURL: &url}, returnValue: &domain.Content{Title: &name, Subtitle: &desc, URL: &url, ExtraData: []string{"Lang: g", "#g "}}, }, + { + Name: "Test no repo data with only updated at", + mockConfig: config.Config{}, + repo: &github.Repository{Language: &lang, HTMLURL: &url, UpdatedAt: &github.Timestamp{Time: updatedAt}}, + returnValue: &domain.Content{URL: &url, ExtraData: []string{"Updated on : 2000-07-12", "#g "}}, + }, { Name: "Test full with username", mockConfig: config.Config{TweetLanguage: true}, @@ -277,8 +284,8 @@ func TestGetContent(t *testing.T) { return &u, nil, nil }, }, - repo: &github.Repository{Name: &name, Description: &desc, Language: &lang, HTMLURL: &url, StargazersCount: &count, Owner: &gu}, - returnValue: &domain.Content{Title: &name, Subtitle: &desc, URL: &url, ExtraData: []string{"Lang: g", "⭐️ 1", "Author: @twitterusername", "#g "}}, + repo: &github.Repository{Name: &name, Description: &desc, Language: &lang, HTMLURL: &url, StargazersCount: &count, Owner: &gu, UpdatedAt: &github.Timestamp{Time: updatedAt}}, + returnValue: &domain.Content{Title: &name, Subtitle: &desc, URL: &url, ExtraData: []string{"Lang: g", "⭐️ 1", "Author: @twitterusername", "Updated on : 2000-07-12", "#g "}}, }, } { t.Run(tc.Name, func(t *testing.T) {