Skip to content

Commit 1f78d12

Browse files
committed
🎨 update code formatting for standard@14
1 parent 8fc6e34 commit 1f78d12

File tree

3 files changed

+70
-58
lines changed

3 files changed

+70
-58
lines changed

lib/helper.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ exports.getPRTitle = (ref, upstream) =>
66
exports.getPRBody = (repoPath, prNumber) =>
77
(prNumber
88
? `See [Commits](/${repoPath}/pull/${prNumber}/commits) and [Changes](/${repoPath}/pull/${prNumber}/files) for more details.\n\n-----\nCreated by [<img src="https://prod.download/pull-18h-svg" valign="bottom"/> **pull[bot]**](https://github.com/wei/pull)`
9-
: `See Commits and Changes for more details.\n\n-----\nCreated by [<img src="https://prod.download/pull-18h-svg" valign="bottom"/> **pull[bot]**](https://github.com/wei/pull)`) +
10-
`. Want to support this open source service? [Please star it : )](https://github.com/wei/pull)`
9+
: 'See Commits and Changes for more details.\n\n-----\nCreated by [<img src="https://prod.download/pull-18h-svg" valign="bottom"/> **pull[bot]**](https://github.com/wei/pull)') +
10+
'. Want to support this open source service? [Please star it : )](https://github.com/wei/pull)'

lib/router.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = app => {
3535
let params
3636
try {
3737
switch (req.params.type) {
38-
case 'installed':
38+
case 'installed': {
3939
const installCount = Object.keys(app.scheduler.INSTALLATIONS).length
4040
params = ('plain' in req.query) ? {
4141
subject: '',
@@ -47,7 +47,8 @@ module.exports = app => {
4747
color: 'blue'
4848
}
4949
break
50-
case 'managing':
50+
}
51+
case 'managing': {
5152
const repoCount = Object.keys(app.scheduler.REPOSITORIES).length
5253
params = ('plain' in req.query) ? {
5354
subject: '',
@@ -59,6 +60,7 @@ module.exports = app => {
5960
color: 'blue'
6061
}
6162
break
63+
}
6264
case 'triggered':
6365
params = ('plain' in req.query) ? {
6466
subject: '',
@@ -157,10 +159,10 @@ module.exports = app => {
157159
.catch(e => {
158160
const output = { statusCode: 400, body: `.github/${app.CONFIG_FILENAME} file has failed validation` }
159161
if (e.message.indexOf('API rate limit exceeded') > -1) {
160-
output.body = `Github API rate limit exceeded`
162+
output.body = 'Github API rate limit exceeded'
161163
} else if (e.message.indexOf('404') > -1) {
162164
output.statusCode = 404
163-
output.body = `File not found`
165+
output.body = 'File not found'
164166
}
165167
app.log.debug(e, `[${fullName}] [.github/${app.CONFIG_FILENAME}] ${output.message}`)
166168
res.status(output.statusCode).end(output.body)

test/pull.test.js

+62-52
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,17 @@ describe('pull - routineCheck', () => {
121121
test('diff too large', async () => {
122122
github.repos.compareCommits.mockImplementation(() => { throw Error('Server Error: Sorry, this diff is taking too long to generate.') })
123123
github.issues.listForRepo.mockResolvedValue({ data: [] })
124-
github.pulls.create.mockResolvedValue({ data: {
125-
number: 12,
126-
base: { ref: 'master' },
127-
head: { ref: 'master', label: 'upstream:master', sha: 'sha1-placeholder-12' },
128-
state: 'open',
129-
user: { login: 'pull[bot]' },
130-
mergeable: true,
131-
mergeable_state: 'clean'
132-
} })
124+
github.pulls.create.mockResolvedValue({
125+
data: {
126+
number: 12,
127+
base: { ref: 'master' },
128+
head: { ref: 'master', label: 'upstream:master', sha: 'sha1-placeholder-12' },
129+
state: 'open',
130+
user: { login: 'pull[bot]' },
131+
mergeable: true,
132+
mergeable_state: 'clean'
133+
}
134+
})
133135

134136
const pull = getPull()
135137
await pull.routineCheck()
@@ -178,38 +180,44 @@ describe('pull - routineCheck', () => {
178180
github.pulls.get.mockImplementation(({ pull_number: number }) => {
179181
switch (number) {
180182
case 12:
181-
return { data: {
182-
number: 12,
183-
base: { ref: 'master', label: 'wei:master' },
184-
head: { ref: 'master', label: 'upstream:master', sha: 'sha1-placeholder-12' },
185-
state: 'open',
186-
user: { login: 'pull[bot]' },
187-
mergeable: true,
188-
rebaseable: true,
189-
mergeable_state: 'clean'
190-
} }
183+
return {
184+
data: {
185+
number: 12,
186+
base: { ref: 'master', label: 'wei:master' },
187+
head: { ref: 'master', label: 'upstream:master', sha: 'sha1-placeholder-12' },
188+
state: 'open',
189+
user: { login: 'pull[bot]' },
190+
mergeable: true,
191+
rebaseable: true,
192+
mergeable_state: 'clean'
193+
}
194+
}
191195
case 13:
192-
return { data: {
193-
number: 13,
194-
base: { ref: 'feature/new-1', label: 'wei:feature/new-1' },
195-
head: { ref: 'dev', label: 'upstream:dev', sha: 'sha1-placeholder-13' },
196-
state: 'open',
197-
user: { login: 'pull[bot]' },
198-
mergeable: true,
199-
rebaseable: true,
200-
mergeable_state: 'clean'
201-
} }
196+
return {
197+
data: {
198+
number: 13,
199+
base: { ref: 'feature/new-1', label: 'wei:feature/new-1' },
200+
head: { ref: 'dev', label: 'upstream:dev', sha: 'sha1-placeholder-13' },
201+
state: 'open',
202+
user: { login: 'pull[bot]' },
203+
mergeable: true,
204+
rebaseable: true,
205+
mergeable_state: 'clean'
206+
}
207+
}
202208
case 14:
203-
return { data: {
204-
number: 14,
205-
base: { ref: 'hotfix/bug-1', label: 'wei:hotfix/bug-1' },
206-
head: { ref: 'dev', label: 'upstream:dev', sha: 'sha1-placeholder-14' },
207-
state: 'open',
208-
user: { login: 'pull[bot]' },
209-
mergeable: true,
210-
rebaseable: true,
211-
mergeable_state: 'clean'
212-
} }
209+
return {
210+
data: {
211+
number: 14,
212+
base: { ref: 'hotfix/bug-1', label: 'wei:hotfix/bug-1' },
213+
head: { ref: 'dev', label: 'upstream:dev', sha: 'sha1-placeholder-14' },
214+
state: 'open',
215+
user: { login: 'pull[bot]' },
216+
mergeable: true,
217+
rebaseable: true,
218+
mergeable_state: 'clean'
219+
}
220+
}
213221
default:
214222
return { data: null }
215223
}
@@ -240,7 +248,7 @@ describe('pull - routineCheck', () => {
240248
expect(github.pulls.get).nthCalledWith(5, { owner: 'wei', repo: 'fork', pull_number: 12 })
241249
expect(github.pulls.get).nthCalledWith(6, { owner: 'wei', repo: 'fork', pull_number: 14 })
242250
expect(github.git.updateRef).toHaveBeenCalledWith(
243-
{ owner: 'wei', repo: 'fork', ref: `heads/hotfix/bug-1`, sha: 'sha1-placeholder-14', force: true }
251+
{ owner: 'wei', repo: 'fork', ref: 'heads/hotfix/bug-1', sha: 'sha1-placeholder-14', force: true }
244252
)
245253

246254
expect(github.pulls.create).not.toHaveBeenCalled()
@@ -253,16 +261,18 @@ describe('pull - routineCheck', () => {
253261
.mockResolvedValueOnce({ data: [{ number: 10 }] })
254262
.mockResolvedValueOnce({ data: [] })
255263
.mockResolvedValueOnce({ data: [] })
256-
github.pulls.get.mockResolvedValueOnce({ data: {
257-
number: 10,
258-
base: { ref: 'master', label: 'wei:master' },
259-
head: { ref: 'master', label: 'upstream:master', sha: 'sha1-placeholder' },
260-
state: 'open',
261-
user: { login: 'pull[bot]' },
262-
mergeable: true,
263-
rebaseable: true,
264-
mergeable_state: 'clean'
265-
} })
264+
github.pulls.get.mockResolvedValueOnce({
265+
data: {
266+
number: 10,
267+
base: { ref: 'master', label: 'wei:master' },
268+
head: { ref: 'master', label: 'upstream:master', sha: 'sha1-placeholder' },
269+
state: 'open',
270+
user: { login: 'pull[bot]' },
271+
mergeable: true,
272+
rebaseable: true,
273+
mergeable_state: 'clean'
274+
}
275+
})
266276
github.pulls.create
267277
.mockResolvedValueOnce({ data: { number: 12 } })
268278
.mockImplementationOnce(() => { throw Error({ code: 512 }) })
@@ -356,7 +366,7 @@ describe('pull - checkAutoMerge', () => {
356366
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 16 })
357367
expect(github.pulls.merge).not.toHaveBeenCalled()
358368
expect(github.git.updateRef).toHaveBeenCalledWith(
359-
{ owner: 'wei', repo: 'fork', ref: `heads/hotfix/bug-1`, sha: 'sha1-placeholder', force: true }
369+
{ owner: 'wei', repo: 'fork', ref: 'heads/hotfix/bug-1', sha: 'sha1-placeholder', force: true }
360370
)
361371
})
362372

@@ -418,7 +428,7 @@ describe('pull - checkAutoMerge', () => {
418428
expect(github.pulls.get).toHaveBeenCalledTimes(1)
419429
expect(github.pulls.get).toHaveBeenCalledWith({ owner: 'wei', repo: 'fork', pull_number: 12 })
420430
expect(github.git.updateRef).toHaveBeenCalledWith(
421-
{ owner: 'wei', repo: 'fork', ref: `heads/hotfix/bug-1`, sha: 'sha1-placeholder', force: true }
431+
{ owner: 'wei', repo: 'fork', ref: 'heads/hotfix/bug-1', sha: 'sha1-placeholder', force: true }
422432
)
423433
})
424434

0 commit comments

Comments
 (0)