Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
save
  • Loading branch information
Nikhil Thorat committed Sep 6, 2019
commit f368440f73bb51bcbefe96167fd7a3dcb028452d
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ bazel-*
build-tmp-napi-v3/
build-tmp-napi-v4/
build/
clone-current/
clone-master/
clone/
coverage/
demo/train-*
deps/
Expand Down
31 changes: 5 additions & 26 deletions scripts/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ const filesWhitelistToTriggerBuild = [
'scripts/diff.js', 'scripts/run-build.sh'
];

const CLONE_MASTER_PATH = 'clone-master';
const CLONE_CURRENT_PATH = 'clone-current';
const CLONE_PATH = 'clone';

const dirs = readdirSync('.').filter(f => {
return f !== 'node_modules' && f !== '.git' && statSync(f).isDirectory();
Expand All @@ -46,33 +45,13 @@ if (branchName == null) {
console.log('commitSha: ', commitSha);
console.log('branchName: ', branchName);

// We cannot do --depth=1 or --single-branch here because we need multiple
// branches at older commits.
// exec(`git clone https://github.com/tensorflow/tfjs ${CLONE_CURRENT_PATH}`);

// // Get the merge base from the current commit and master.
// shell.cd(CLONE_CURRENT_PATH);
// exec(`git checkout ${branchName}`);
// const mergeBase = exec(`git merge-base master ${branchName}`).stdout.trim();
// const res = shell.exec(`git checkout ${commitSha}`);
// let CURRENT_DIFF_PATH = CLONE_CURRENT_PATH;
// if (res.code !== 0) {
// console.log(`${commitSha} does not exist. PR coming from a fork.`);

// // Since we're coming from a fork we can't clone the fork so we'll diff
// // against what's checked out locally.
// CURRENT_DIFF_PATH = '.';
// }
// shell.cd('..');


// We cannot do --depth=1 here because we need to check out an old merge base.
// We cannot do --single-branch here because we need multiple branches.
exec(
`git clone ` +
`https://github.com/tensorflow/tfjs ${CLONE_MASTER_PATH}`);
`https://github.com/tensorflow/tfjs ${CLONE_PATH}`);

shell.cd(CLONE_MASTER_PATH);
shell.cd(CLONE_PATH);
exec(`git checkout ${branchName}`);
const mergeBase = exec(`git merge-base master ${branchName}`).stdout.trim();
exec(`git fetch origin ${mergeBase}`);
Expand All @@ -97,7 +76,7 @@ console.log();

let triggeredBuilds = [];
dirs.forEach(dir => {
shell.rm(`${dir}/diff`);
shell.rm('-f', `${dir}/diff`);
const diffOutput = diff(`${dir}/`);
if (diffOutput !== '') {
console.log(`${dir} has modified files.`);
Expand All @@ -124,7 +103,7 @@ console.log('Triggering builds for ', triggeredBuilds.join(', '));

function diff(fileOrDirName) {
const diffCmd = `diff -rq ` +
`${CLONE_MASTER_PATH}/${fileOrDirName} ` +
`${CLONE_PATH}/${fileOrDirName} ` +
`${fileOrDirName}`;
return exec(diffCmd, {silent: true}, true).stdout.trim();
}