Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit da2c7aa

Browse files
author
Chris McIntosh
committed
adding since/until to repo pulls command
1 parent 8028b61 commit da2c7aa

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

packages/cli/README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $ npm install -g @github/github-artifact-exporter-cli
2525
$ github-artifacts-exporter COMMAND
2626
running command...
2727
$ github-artifacts-exporter (-v|--version|version)
28-
@github/github-artifact-exporter-cli/2.0.1 darwin-x64 node-v14.4.0
28+
@github/github-artifact-exporter-cli/2.0.1 darwin-x64 node-v16.2.0
2929
$ github-artifacts-exporter --help [COMMAND]
3030
USAGE
3131
$ github-artifacts-exporter COMMAND
@@ -105,7 +105,7 @@ OPTIONS
105105
--token=token (required) GitHub personal access token
106106
```
107107

108-
_See code: [src/commands/repo.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/packages/cli/src/commands/repo.ts)_
108+
_See code: [src/commands/repo.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/src/commands/repo.ts)_
109109

110110
## `github-artifacts-exporter repo:commits`
111111

@@ -126,7 +126,7 @@ OPTIONS
126126
--until=until search commits created before yyyy-mm-dd
127127
```
128128

129-
_See code: [src/commands/repo/commits.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/packages/cli/src/commands/repo/commits.ts)_
129+
_See code: [src/commands/repo/commits.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/src/commands/repo/commits.ts)_
130130

131131
## `github-artifacts-exporter repo:milestones`
132132

@@ -144,7 +144,7 @@ OPTIONS
144144
--token=token (required) GitHub personal access token
145145
```
146146

147-
_See code: [src/commands/repo/milestones.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/packages/cli/src/commands/repo/milestones.ts)_
147+
_See code: [src/commands/repo/milestones.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/src/commands/repo/milestones.ts)_
148148

149149
## `github-artifacts-exporter repo:projects`
150150

@@ -163,7 +163,7 @@ OPTIONS
163163
--token=token (required) GitHub personal access token
164164
```
165165

166-
_See code: [src/commands/repo/projects.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/packages/cli/src/commands/repo/projects.ts)_
166+
_See code: [src/commands/repo/projects.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/src/commands/repo/projects.ts)_
167167

168168
## `github-artifacts-exporter repo:pulls`
169169

@@ -178,10 +178,12 @@ OPTIONS
178178
--format=(JSONL|JSON|CSV) [default: JSONL] export format
179179
--owner=owner (required) GitHub repository owner
180180
--repo=repo (required) GitHub repository name
181+
--since=since search pull requests created after yyyy-mm-dd
181182
--token=token (required) GitHub personal access token
183+
--until=until search pull requests created before yyyy-mm-dd
182184
```
183185

184-
_See code: [src/commands/repo/pulls.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/packages/cli/src/commands/repo/pulls.ts)_
186+
_See code: [src/commands/repo/pulls.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/src/commands/repo/pulls.ts)_
185187

186188
## `github-artifacts-exporter repo:releases`
187189

@@ -199,7 +201,7 @@ OPTIONS
199201
--token=token (required) GitHub personal access token
200202
```
201203

202-
_See code: [src/commands/repo/releases.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/packages/cli/src/commands/repo/releases.ts)_
204+
_See code: [src/commands/repo/releases.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/src/commands/repo/releases.ts)_
203205

204206
## `github-artifacts-exporter search`
205207

@@ -217,7 +219,7 @@ OPTIONS
217219
--token=token (required) GitHub personal access token
218220
```
219221

220-
_See code: [src/commands/search.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/packages/cli/src/commands/search.ts)_
222+
_See code: [src/commands/search.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/src/commands/search.ts)_
221223

222224
## `github-artifacts-exporter search:issues`
223225

@@ -244,5 +246,5 @@ OPTIONS
244246
--updatedUntil=updatedUntil search issues updated before yyyy-mm-dd
245247
```
246248

247-
_See code: [src/commands/search/issues.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/packages/cli/src/commands/search/issues.ts)_
249+
_See code: [src/commands/search/issues.ts](https://github.com/github/github-artifact-exporter/blob/v2.0.1/src/commands/search/issues.ts)_
248250
<!-- commandsstop -->

packages/cli/src/commands/repo/pulls.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,17 @@ export default class RepoPulls extends BaseCommand {
105105
description: "GitHub repository owner",
106106
required: true,
107107
}),
108-
109108
repo: flagTypes.string({
110109
dependsOn: ["owner"],
111110
description: "GitHub repository name",
112111
required: true,
113112
}),
113+
since: flagTypes.string({
114+
description: "search pull requests created after yyyy-mm-dd",
115+
}),
116+
until: flagTypes.string({
117+
description: "search pull requests created before yyyy-mm-dd",
118+
}),
114119
};
115120

116121
async fetchPulls(query: string, owner: string, repo: string) {
@@ -179,9 +184,21 @@ export default class RepoPulls extends BaseCommand {
179184

180185
async run() {
181186
const { flags } = this.parse(RepoPulls);
182-
const { owner, repo, format } = flags;
187+
const { owner, repo, format, since, until } = flags;
188+
189+
let pulls = await this.fetchPulls(LIST_PULLS_QUERY, owner, repo);
183190

184-
const pulls = await this.fetchPulls(LIST_PULLS_QUERY, owner, repo);
191+
// filter out pulls before since or after until
192+
if (since) {
193+
pulls = pulls.filter((pull) => {
194+
return +new Date(pull.createdAt) >= +new Date(since);
195+
});
196+
}
197+
if (until) {
198+
pulls = pulls.filter((pull) => {
199+
return +new Date(until) >= +new Date(pull.createdAt);
200+
});
201+
}
185202

186203
const pullsWithComments = pulls.filter(
187204
(issue) => issue.comments.totalCount - issue.comments.nodes.length > 0

0 commit comments

Comments
 (0)