Skip to content

Commit

Permalink
Merge pull request #1 from philips-forks/bugfix/multi-commit-removed-…
Browse files Browse the repository at this point in the history
…files-robustness

Check for deleted files
  • Loading branch information
pbronneberg authored Apr 7, 2022
2 parents 7795d4e + 61daca2 commit 610f271
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ const markdownExtensions = [
export function retrieveCodes(files) {
return files.reduce((accum, f) => {
const p = path.parse(f);
if (!fs.existsSync(path)) {
return accum;
}

if (umlFileExtensions.indexOf(p.ext) !== -1) {
return accum.concat({
name: p.name,
// TODO: files may have been deleted.
code: fs.readFileSync(f).toString(),
dir: p.dir
});
}
if (markdownExtensions.indexOf(p.ext) !== -1) {
// TODO: files may have been deleted.
const content = fs.readFileSync(f).toString();
const dir = path.dirname(f);
const codes = puFromMd(content);
Expand Down Expand Up @@ -93,6 +95,7 @@ export async function getCommitsFromPayload(octokit, payload) {
export function updatedFiles(commits) {
return uniq(commits.reduce(
(accum: any[], commit) => accum.concat(
//This does not filter out files that got changed and removed in multiple commits
commit.files.filter(f => f.status !== 'removed').map(f => f.filename)
),
[]
Expand Down

0 comments on commit 610f271

Please sign in to comment.