Skip to content

Commit a4da07a

Browse files
authored
Merge pull request #89 from dscho/fix-curl-rc-version-exclusion
Fix cURL rc version exclusion
2 parents aa3a20e + aa4678a commit a4da07a

File tree

4 files changed

+77
-7
lines changed

4 files changed

+77
-7
lines changed

__tests__/index.test.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,65 @@ Signed-off-by: Johannes Schindelin <[email protected]>
123123
https://github.com/git-for-windows/rss-to-issues/commit/394ee852b18c5e3bca536b585cbb95d32ce77057`
124124
})
125125
})
126+
127+
test('curl -rc versions', async () => {
128+
mockHTTPSGet.__RETURN__ = `<?xml version="1.0" encoding="UTF-8"?>
129+
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US">
130+
<id>tag:github.com,2008:https://github.com/curl/curl/releases</id>
131+
<link type="text/html" rel="alternate" href="https://github.com/curl/curl/releases"/>
132+
<link type="application/atom+xml" rel="self" href="https://github.com/curl/curl/releases.atom"/>
133+
<title>Tags from curl</title>
134+
<updated>2025-06-30T11:34:35Z</updated>
135+
<entry>
136+
<id>tag:github.com,2008:Repository/569041/rc-8_15_0-2</id>
137+
<updated>2025-06-30T11:34:35Z</updated>
138+
<link rel="alternate" type="text/html" href="https://github.com/curl/curl/releases/tag/rc-8_15_0-2"/>
139+
<title>rc-8_15_0-2</title>
140+
<content></content>
141+
<author>
142+
<name>bagder</name>
143+
</author>
144+
<media:thumbnail height="30" width="30" url="https://avatars.githubusercontent.com/u/177011?s=60&amp;v=4"/>
145+
</entry>
146+
<entry>
147+
<id>tag:github.com,2008:Repository/569041/rc-8_15_0-1</id>
148+
<updated>2025-06-21T09:50:00Z</updated>
149+
<link rel="alternate" type="text/html" href="https://github.com/curl/curl/releases/tag/rc-8_15_0-1"/>
150+
<title>rc-8_15_0-1</title>
151+
<content></content>
152+
<author>
153+
<name>bagder</name>
154+
</author>
155+
<media:thumbnail height="30" width="30" url="https://avatars.githubusercontent.com/u/177011?s=60&amp;v=4"/>
156+
</entry>
157+
<entry>
158+
<id>tag:github.com,2008:Repository/569041/curl-8_14_1</id>
159+
<updated>2025-06-04T05:59:07Z</updated>
160+
<link rel="alternate" type="text/html" href="https://github.com/curl/curl/releases/tag/curl-8_14_1"/>
161+
<title>8.14.1</title>
162+
<content></content>
163+
<author>
164+
<name>bagder</name>
165+
</author>
166+
<media:thumbnail height="30" width="30" url="https://avatars.githubusercontent.com/u/177011?s=60&amp;v=4"/>
167+
</entry>
168+
</feed>`
169+
octokit.rest.issues.listForRepo.mockReturnValueOnce({ data: [] })
170+
Object.assign(core.__INPUTS__, {
171+
'max-age': '9999d',
172+
prefix: '[New curl version]',
173+
'title-pattern': '^(?!rc-)'
174+
})
175+
await run()
176+
177+
expect(https.get).toHaveBeenCalledTimes(1)
178+
expect(octokit.rest.issues.listForRepo).toHaveBeenCalledTimes(1)
179+
expect(octokit.rest.issues.create).toHaveBeenCalledTimes(1)
180+
expect(octokit.rest.issues.create).toHaveBeenCalledWith({
181+
owner: 'owner',
182+
repo: 'repo',
183+
title: '[New curl version] 8.14.1',
184+
body: '\n\nhttps://github.com/curl/curl/releases/tag/curl-8_14_1',
185+
labels: undefined
186+
})
187+
})

dist/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,15 @@ const run = async () => {
8787
// Iterate
8888
let counter = 0
8989
for (const item of feed.items) {
90-
const title = `${issueTitlePrefix}${item.title || (item.pubDate && new Date(item.pubDate).toUTCString())}`
91-
if (titlePattern && !title.match(titlePattern)) {
92-
core.debug(`Feed item skipped because it does not match the title pattern (${title})`)
90+
if (!item.title && (titlePattern || !item.pubDate)) {
91+
core.debug(`Feed item ${JSON.stringify(item)} skipped because it has no title`)
9392
continue
9493
}
94+
if (titlePattern && !item.title.match(titlePattern)) {
95+
core.debug(`Feed item skipped because it does not match the title pattern (${item.title})`)
96+
continue
97+
}
98+
const title = `${issueTitlePrefix}${item.title || new Date(item.pubDate).toUTCString()}`
9599

96100
core.debug(`Issue '${title}'`)
97101

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,15 @@ const run = async () => {
8181
// Iterate
8282
let counter = 0
8383
for (const item of feed.items) {
84-
const title = `${issueTitlePrefix}${item.title || (item.pubDate && new Date(item.pubDate).toUTCString())}`
85-
if (titlePattern && !title.match(titlePattern)) {
86-
core.debug(`Feed item skipped because it does not match the title pattern (${title})`)
84+
if (!item.title && (titlePattern || !item.pubDate)) {
85+
core.debug(`Feed item ${JSON.stringify(item)} skipped because it has no title`)
8786
continue
8887
}
88+
if (titlePattern && !item.title.match(titlePattern)) {
89+
core.debug(`Feed item skipped because it does not match the title pattern (${item.title})`)
90+
continue
91+
}
92+
const title = `${issueTitlePrefix}${item.title || new Date(item.pubDate).toUTCString()}`
8993

9094
core.debug(`Issue '${title}'`)
9195

0 commit comments

Comments
 (0)