Skip to content

Commit 2cc7a53

Browse files
authored
Merge pull request #100 from gavinr/milestone-fix
Milestone fix
2 parents 9919fc6 + 634853c commit 2cc7a53

File tree

9 files changed

+5455
-5167
lines changed

9 files changed

+5455
-5167
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v3
1313
with:
1414
fetch-depth: 0
1515
- name: Setup Node.js
16-
uses: actions/setup-node@v2
16+
uses: actions/setup-node@v3
1717
with:
18-
node-version: 'lts/*'
18+
node-version: "lts/*"
1919
- name: Install dependencies
2020
run: npm ci
2121
- name: Release

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions/setup-node@v1
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-node@v3
12+
with:
13+
node-version: "lts/*"
1214
- run: npm ci
1315
- run: npm run build --if-present
1416
- run: npm test

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Instructions for exporting or importing:
3232

3333
### To Import Issues
3434

35-
Currently imports title, body, labels, status (closed or open) and milestones.
35+
Currently imports title, body, labels, status (closed or open) and milestones. See the [test](/test) folder for example input formats.
3636

3737
```bash
3838
githubCsvTools myFile.csv

helpers.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
const createIssue = (octokit, issueInfo, organization, repository) => {
22
return new Promise((resolve, reject) => {
3-
octokit.request("POST /repos/" + organization + "/" + repository + "/import/issues", issueInfo).then(
4-
(res) => {
5-
// console.log("res", res);
6-
if (res.status === 202) {
3+
octokit
4+
.request(
5+
"POST /repos/" + organization + "/" + repository + "/import/issues",
6+
issueInfo
7+
)
8+
.then(
9+
(res) => {
10+
// console.log("res", res);
11+
if (res.status === 202) {
712
console.log(`Imported issue: ${issueInfo.issue.title}`);
813
resolve(res);
9-
} else {
10-
// error creating the issue
11-
reject(res);
14+
} else {
15+
// error creating the issue
16+
reject(res);
17+
}
18+
},
19+
(err) => {
20+
reject(err);
1221
}
13-
},
14-
(err) => {
15-
reject(err);
16-
}
17-
);
22+
);
1823
});
1924
};
2025

import.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const importFile = (octokit, file, values) => {
1616
},
1717
(err, csvRows) => {
1818
if (err) throw err;
19-
const cols = csvRows[0].map(col => col.toLowerCase());
19+
const cols = csvRows[0].map((col) => col.toLowerCase());
2020
csvRows.shift();
2121

2222
// get indexes of the fields we need
@@ -33,7 +33,7 @@ const importFile = (octokit, file, values) => {
3333
}
3434
const createPromises = csvRows.map((row) => {
3535
const sendObj = {
36-
issue : {}
36+
issue: {},
3737
};
3838

3939
sendObj.issue.title = row[titleIndex];
@@ -50,7 +50,7 @@ const importFile = (octokit, file, values) => {
5050

5151
// if we have a milestone column, pass that.
5252
if (milestoneIndex > -1 && row[milestoneIndex] !== "") {
53-
sendObj.issue.milestone = row[milestoneIndex];
53+
sendObj.issue.milestone = Number(row[milestoneIndex]);
5454
}
5555

5656
// if we have an assignee column, pass that.
@@ -61,16 +61,25 @@ const importFile = (octokit, file, values) => {
6161
if (stateIndex > -1 && row[stateIndex].toLowerCase() === "closed") {
6262
sendObj.issue.closed = true;
6363
}
64-
return createIssue(octokit, sendObj, values.userOrOrganization, values.repo);
64+
return createIssue(
65+
octokit,
66+
sendObj,
67+
values.userOrOrganization,
68+
values.repo
69+
);
6570
});
6671

6772
Promise.all(createPromises).then(
6873
(res) => {
6974
const successes = res.filter((cr) => {
70-
return cr.status === 200 || cr.status === 201 || cr.status === 202;
75+
return (
76+
cr.status === 200 || cr.status === 201 || cr.status === 202
77+
);
7178
});
7279
const fails = res.filter((cr) => {
73-
return cr.status !== 200 && cr.status !== 201 && cr.status !== 202;
80+
return (
81+
cr.status !== 200 && cr.status !== 201 && cr.status !== 202
82+
);
7483
});
7584

7685
console.log(
@@ -81,7 +90,7 @@ const importFile = (octokit, file, values) => {
8190
);
8291

8392
if (fails.length > 0) {
84-
console.error('ERROR - some of the imports have failed');
93+
console.error("ERROR - some of the imports have failed");
8594
console.log(fails);
8695
}
8796

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { importFile } = require("./import.js");
1010
const { exportIssues } = require("./export.js");
1111

1212
program
13-
.version(require('./package.json').version)
13+
.version(require("./package.json").version)
1414
.arguments("[file]")
1515
.option(
1616
"-g, --github_enterprise [https://api.github.my-company.com]",

0 commit comments

Comments
 (0)