Skip to content

Commit

Permalink
Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
DerJuulsn committed Jan 24, 2022
1 parent f470303 commit b7876a0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/ArgumentContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const argumentContext = {

taskSystem: inputParser.getInput("taskSystem", {type: "string", default: "GitHub"}) as string,

importAll: github.event?.inputs?.importAll as string === 'true',
importAll: github?.context?.payload?.inputs?.importAll as boolean,

reopenClosed: inputParser.getInput("reopenClosed", {type: "boolean", default: true}) as boolean

}
};
5 changes: 3 additions & 2 deletions src/GitHubContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ async function getDiffFile() {
const diff = await getDiff();
if (diff)
return diff.data
} catch {
console.error("Diff file is too big")
} catch (e) {
console.error(e)
console.error("Diff file might be too big")
return
}
}
Expand Down
24 changes: 15 additions & 9 deletions src/Todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,26 @@ async function generateTodosFromCommit() {

const todos: Todo[] = []

// Get the diff for this commit or PR
const diff = await getDiffFile()
if (!diff) return todos

// Ensure that all the labels we need are present
const labels = await getLabels()

if (!argumentContext.keywords.length) return todos

// RegEx that matches lines with the configured keywords
const regex = new RegExp(`^(?<beforeTag>\\W+)(?<keyword>${argumentContext.keywords.join('|')})\\b\\W*(?<title>.*)`, (!argumentContext.caseSensitive ? 'i' : ''))

// Parse the diff as files or import all
const files: File[] = argumentContext.importAll ? importEverything() : parseDiff(diff)
let files: File[];

// Diff as files or import all
if (argumentContext.importAll) {
files = importEverything();
} else {
// Get the diff for this commit or PR
const diff = await getDiffFile()
if (!diff) return todos

files = parseDiff(diff)
}

// Ensure that all the labels we need are present
const labels = await getLabels()

await Promise.all(files.map(async file => {
if(!file.to) return
Expand Down
4 changes: 2 additions & 2 deletions src/TodoHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export async function addTodo(todo: Todo) {

console.log(`Creating issue [${todo.title}]`)

await sleep(1000);

const val = await octokit.issues.create({
...repoContext.repoObject,
title: todo.title,
Expand All @@ -35,6 +33,8 @@ export async function addTodo(todo: Todo) {

todo.issueId = val.data.number;

await sleep(1000);

console.log(`Issue [${todo.title}] got ID ${todo.issueId}`)
}

Expand Down
4 changes: 3 additions & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export function stripAt(str: string) {

export function assignFlow(author: string) : string[] {
if (argumentContext.autoAssign === true) {
return [author]
if(author)
return [author]
return []
} else if (argumentContext.autoAssign) {
return argumentContext.autoAssign.map((n: string) => stripAt(n))
}
Expand Down

0 comments on commit b7876a0

Please sign in to comment.