1
0
mirror of https://github.com/badges/shields.git synced 2025-07-29 06:21:16 +03:00

[GithubLastCommit] [GitlabLastCommit] [GiteaLastCommit] Support file path for last commit (#10041)

* Support file path for GitHub last commit

* Support file path for GitLab last commit

* Support file path for Gitea last commit

* Define common `relativeUri` validator

* Sort imports

* Add more tests for path variations

* Fix test name

Co-authored-by: chris48s <chris48s@users.noreply.github.com>

* Update Gitea 404 message

* Handle case when no commits are returned for GitHub and GitLab

---------

Co-authored-by: chris48s <chris48s@users.noreply.github.com>
This commit is contained in:
ReubenFrankel
2024-03-25 12:10:04 +00:00
committed by GitHub
parent 9fd5546842
commit 4f141dfa84
8 changed files with 188 additions and 29 deletions

View File

@ -8,13 +8,43 @@ t.create('last commit (recent)').get('/gitlab-org/gitlab.json').expectBadge({
message: isFormattedDate,
})
t.create('last commit (on ref and ancient)')
t.create('last commit (on ref) (ancient)')
.get('/gitlab-org/gitlab.json?ref=v13.8.6-ee')
.expectBadge({
label: 'last commit',
message: 'march 2021',
})
t.create('last commit (on ref) (ancient) (by top-level file path)')
.get('/gitlab-org/gitlab.json?ref=v13.8.6-ee&path=README.md')
.expectBadge({
label: 'last commit',
message: 'december 2020',
})
t.create('last commit (on ref) (ancient) (by top-level dir path)')
.get('/gitlab-org/gitlab.json?ref=v13.8.6-ee&path=changelogs')
.expectBadge({
label: 'last commit',
message: 'march 2021',
})
t.create(
'last commit (on ref) (ancient) (by top-level dir path with trailing slash)',
)
.get('/gitlab-org/gitlab.json?ref=v13.8.6-ee&path=changelogs/')
.expectBadge({
label: 'last commit',
message: 'march 2021',
})
t.create('last commit (on ref) (ancient) (by nested file path)')
.get('/gitlab-org/gitlab.json?ref=v13.8.6-ee&path=changelogs/README.md')
.expectBadge({
label: 'last commit',
message: 'september 2020',
})
t.create('last commit (self-managed)')
.get('/gitlab-cn/gitlab.json?gitlab_url=https://jihulab.com')
.expectBadge({
@ -28,3 +58,10 @@ t.create('last commit (project not found)')
label: 'last commit',
message: 'project not found',
})
t.create('last commit (no commits found)')
.get('/gitlab-org/gitlab.json?path=not/a/dir')
.expectBadge({
label: 'last commit',
message: 'no commits found',
})