-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from github-tooling/changes-entry-1
Changes entry 1
- Loading branch information
Showing
5 changed files
with
41 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const fs = require('fs'); | ||
const { execSync } = require('child_process') | ||
|
||
const tsGraph = require('@andriyorehov/ts-graph'); | ||
|
||
|
||
module.exports = async ({ github, context }) => { | ||
const { commits } = context.payload.pull_request | ||
|
||
const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits}`).toString() | ||
const changedFiles = rawFiles.split('\n').filter(Boolean) | ||
|
||
const owners = fs.readFileSync('owners.json', 'utf8'); | ||
const ownersObj = JSON.parse(owners); | ||
|
||
for (const owner of ownersObj) { | ||
for (const entries of owner.owns) { | ||
const paths = Object.keys(tsGraph.getTreeByFile(entries).flatTree); | ||
if (changedFiles.some(file => paths.includes(file))) { | ||
execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer ${owner.team}`) | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import fs from 'fs'; | ||
const fs = require('fs'); | ||
|
||
import { getTreeByFile } from '@andriyorehov/ts-graph'; | ||
const tsGraph = require('@andriyorehov/ts-graph'); | ||
|
||
const owners = fs.readFileSync('owners.json', 'utf8'); | ||
const ownersObj = JSON.parse(owners); | ||
|
||
for (const owner of ownersObj) { | ||
for (const entries of owner.owns) { | ||
console.log(entries); | ||
console.log(Object.keys(getTreeByFile(entries).flatTree)); | ||
console.log(Object.keys(tsGraph.getTreeByFile(entries).flatTree)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const nested = 'nested'; | ||
export const nested = 'nested-new-'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
[ | ||
{ | ||
"team": "entry1", | ||
"team": "github-tooling/entry1", | ||
"owns": ["main/entry1/main.ts"] | ||
}, | ||
{ | ||
"team": "entry2", | ||
"team": "github-tooling/entry2", | ||
"owns": ["main/entry2/main.ts"] | ||
} | ||
] |