Skip to content

Commit 1ce5307

Browse files
authored
Merge pull request #39 from richkuz/master
Fix error when label is removed from issue
2 parents 50faaa3 + 0312958 commit 1ce5307

4 files changed

Lines changed: 35 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ npm-debug.log*
55
yarn-debug.log*
66
yarn-error.log*
77
lerna-debug.log*
8+
.DS_Store
89

910
# Diagnostic reports (https://nodejs.org/api/report.html)
1011
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

project-assigner/__tests__/project-assigner.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,34 @@ describe("projectAssigner", () => {
241241
expect(JSON.stringify(projectAssigner.normalizedGithubContext(mockPRsGithubContext)))
242242
.toBe(JSON.stringify(mockPRsContext));
243243
});
244+
245+
it("returns a normalied context when no label specified, such as when a label has been removed", () => {
246+
const mockPRsGithubContext = {
247+
payload: {
248+
repository: {
249+
owner: {
250+
login: 'mocked_owner'
251+
},
252+
name: 'repo1'
253+
},
254+
pull_request: {
255+
number: 543,
256+
node_id: 'mocked_pr_node_id'
257+
}
258+
},
259+
eventName: 'pull_request'
260+
};
261+
expect(JSON.stringify(projectAssigner.normalizedGithubContext(mockPRsGithubContext)))
262+
.toBe(JSON.stringify({
263+
owner: 'mocked_owner',
264+
repo: 'repo1',
265+
itemType: 'Pull request',
266+
itemNumber: 543,
267+
itemNodeId: 'mocked_pr_node_id',
268+
itemQuery: 'pullRequest(number: 543)',
269+
projectCardsPath: 'repository.pullRequest.projectCards.edges',
270+
}));
271+
});
244272
});
245273

246274
describe("removeCard", () => {

project-assigner/dist/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28516,7 +28516,9 @@ class ProjectAssigner {
2851628516
const context = {
2851728517
owner: githubContext.payload.repository.owner.login,
2851828518
repo: githubContext.payload.repository.name,
28519-
labelName: githubContext.payload.label.name,
28519+
}
28520+
if (githubContext.payload.label) {
28521+
context['labelName'] = githubContext.payload.label.name;
2852028522
}
2852128523
if (githubContext.eventName == "issues") {
2852228524
context['itemType'] = 'Issue';

project-assigner/project-assigner.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ class ProjectAssigner {
239239
const context = {
240240
owner: githubContext.payload.repository.owner.login,
241241
repo: githubContext.payload.repository.name,
242-
labelName: githubContext.payload.label.name,
242+
}
243+
if (githubContext.payload.label) {
244+
context['labelName'] = githubContext.payload.label.name;
243245
}
244246
if (githubContext.eventName == "issues") {
245247
context['itemType'] = 'Issue';

0 commit comments

Comments
 (0)