Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Danger reports tasks in reverse order #82

Closed
Samasaur1 opened this issue Jul 9, 2020 · 0 comments · Fixed by #86
Closed

Danger reports tasks in reverse order #82

Samasaur1 opened this issue Jul 9, 2020 · 0 comments · Fixed by #86
Labels
internal change Something that only changes on the inside low priority Something that is not urgent

Comments

@Samasaur1
Copy link
Owner

When making a PR to master, Danger is run. Recently, I upgraded the Danger configuration so that it checks the PR body for incomplete tasks, replacing task-list-completed. However, Danger reports these tasks in reverse order, whether or not they are completed. I understand why this happens, but it's annoying.

Here's the code that does it:

DiceKit/Dangerfile.swift

Lines 103 to 125 in e8876a1

// Check for incomplete tasks in the PR body
// Note the difference between the first regex and the later two ("\n" vs "^").
// That's the "start of string" character, which I only want to match after I've split
// on "\n". Therefore, this only matches lines that start with a task,
// which excludes nested tasks.
if let body = danger.github.pullRequest.body {
if body.range(of: #"\n- \[[x ]\] "#, options: .regularExpression) != nil {
let split = body.split { $0.isNewline }
let allTaskLines = split
.filter { $0.range(of: #"^- \[[x ]\] "#, options: .regularExpression) != nil }
for (num, line) in allTaskLines.enumerated() {
if line.range(of: #"^- \[x\] "#, options: .regularExpression) != nil {
message("**Task \(num + 1) completed:** \(line.dropFirst(6))")
continue
}
fail("**Task \(num + 1) incomplete:** \(line.dropFirst(6))") // "- [ ] "
}
} else {
warn("PR body doesn't appear to have any tasks, which it should")
}
} else {
warn("Cannot fetch PR body!")
}

It should be relatively simple to reverse it — probably just allTaskLines.enumerated().reversed()

@Samasaur1 Samasaur1 added low priority Something that is not urgent internal change Something that only changes on the inside labels Jul 9, 2020
@ghost ghost added the Pending PR label Oct 1, 2020
@ghost ghost removed the Pending PR label Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal change Something that only changes on the inside low priority Something that is not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant