MCPcopy Index your code
hub / github.com/tensorflow/tfjs / findPackagesWithDiff

Function findPackagesWithDiff

scripts/find_packages_with_diff.js:40–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38
39
40function findPackagesWithDiff() {
41 // For Nightly build, baseBranch is one of the falsey values. We use master
42 // for Nightly build.
43 if (!baseBranch) {
44 baseBranch = 'master';
45 }
46 console.log('commitSha: ', commitSha);
47 console.log('branchName: ', branchName);
48 console.log('baseBranch: ', baseBranch);
49
50 // We cannot do --depth=1 here because we need to check out an old merge base.
51 // We cannot do --single-branch here because we need multiple branches.
52 console.log(`Clone branch ${baseBranch}`);
53 shell.rm('-rf', CLONE_PATH);
54 exec(`git clone -b ${baseBranch} https://github.com/tensorflow/tfjs ${
55 CLONE_PATH}`);
56
57 console.log(); // Break up the console for readability.
58
59 const originalPath = process.cwd();
60 shell.cd(CLONE_PATH);
61
62 // If we cannot check out the commit then this PR is coming from a fork.
63 const res = shell.exec(`git checkout ${commitSha}`, {silent: true});
64 const isPullRequestFromFork = res.code !== 0;
65
66 // Only checkout the merge base if the pull requests comes from a
67 // tensorflow/tfjs branch. Otherwise clone master and diff against master.
68 if (!isPullRequestFromFork) {
69 console.log('PR is coming from tensorflow/tfjs. Finding the merge base...');
70 exec(`git checkout ${branchName}`);
71 const mergeBase =
72 exec(`git merge-base ${baseBranch} ${branchName}`).stdout.trim();
73 exec(`git fetch origin ${mergeBase}`);
74 exec(`git checkout ${mergeBase}`);
75 console.log('mergeBase: ', mergeBase);
76 } else {
77 console.log(`PR is going to diff against branch ${baseBranch}.`);
78 }
79 shell.cd(originalPath);
80 console.log(); // Break up the console for readability.
81
82 let triggerAllBuilds = false;
83 let allowlistDiffOutput = [];
84 filesAllowlistToTriggerBuild.forEach(fileToTriggerBuild => {
85 const diffOutput = diff(fileToTriggerBuild);
86 if (diffOutput !== '') {
87 console.log(fileToTriggerBuild, 'has changed. Triggering all builds.');
88 triggerAllBuilds = true;
89 allowlistDiffOutput.push(diffOutput);
90 }
91 });
92
93 console.log(); // Break up the console for readability.
94
95 let packagesWithDiff = [];
96 allPackages.forEach(dir => {
97 const diffOutput = diff(`${dir}/`);

Calls 5

execFunction · 0.85
diffFunction · 0.85
joinMethod · 0.80
logMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…