Skip to content

Commit 7e60388

Browse files
committed
Fix habits plugin: safer commit object handling to prevent destructuring errors
1 parent 29d9cba commit 7e60388

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

source/plugins/habits/index.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ export default async function({login, data, rest, imports, q, account}, {enabled
4848
...await Promise.allSettled(
4949
commits
5050
.flatMap(({payload}) => payload?.commits ?? [])
51-
.filter(commit => commit != null) // Filter out null/undefined commits
52-
.filter(({author}) => {
53-
// Handle missing author property
51+
.filter(commit => commit != null && typeof commit === 'object') // Filter out null/undefined commits and ensure it's an object
52+
.filter(commit => {
53+
// Safely check author property
54+
const author = commit?.author
5455
if (!author) return false
5556
return data.shared["commits.authoring"].filter(authoring => author?.login?.toLocaleLowerCase().includes(authoring) || author?.email?.toLocaleLowerCase().includes(authoring) || author?.name?.toLocaleLowerCase().includes(authoring)).length
5657
})

0 commit comments

Comments
 (0)