Skip to content

Commit 81623c4

Browse files
Update dependency workspace-tools to ^0.40.0 (#1094)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Elizabeth Craig <elcraig@microsoft.com>
1 parent 4af7ddb commit 81623c4

18 files changed

Lines changed: 45 additions & 39 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Update dependency workspace-tools to ^0.40.0. This may improve detection of remote branch names in certain cases. It also includes stricter error checking for git operations, which may surface some errors which were previously hidden.",
4+
"packageName": "beachball",
5+
"email": "elcraig@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"prompts": "^2.4.2",
5757
"semver": "^7.0.0",
5858
"toposort": "^2.0.2",
59-
"workspace-tools": "^0.38.2",
59+
"workspace-tools": "^0.40.0",
6060
"yargs-parser": "^21.0.0"
6161
},
6262
"devDependencies": {

src/__fixtures__/gitDefaults.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type git, gitFailFast } from 'workspace-tools';
1+
import { gitFailFast, type GitOptions } from 'workspace-tools';
22

33
export const defaultBranchName = 'master';
44
export const defaultRemoteName = 'origin';
@@ -26,6 +26,6 @@ export function setDefaultBranchName(cwd: string, isRemoteRepo?: boolean): void
2626
* (This should NOT be used to make full snapshots of git logs, or as the primary means of testing.
2727
* But it can be useful for allowing backup checks for absence of strings like "warning" or "fatal".)
2828
*/
29-
export function optsWithLang(opts?: Parameters<typeof git>[1]): Parameters<typeof git>[1] {
29+
export function optsWithLang(opts: GitOptions): GitOptions {
3030
return { ...opts, env: { ...opts?.env, LANG: 'en_US.UTF-8' } };
3131
}

src/__fixtures__/repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class Repository {
7070
// Git logs are localized, so attempt to force this operation to use English so that the
7171
// warning check below works consistently. (It's not a big issue if it doesn't work, because
7272
// the warning check is just intended to make local test development easier in uncommon cases.)
73-
optsWithLang()
73+
optsWithLang({ cwd: this.rootPath })
7474
);
7575

7676
// If git clone gives any warnings besides "you appear to have cloned an empty repository"

src/__functional__/changefile/writeChangeFiles.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('writeChangeFiles', () => {
6464
expect(cleanChangeFilePaths(repo.rootPath, changeFiles)).toEqual(expectedFiles);
6565

6666
// and tracked
67-
const trackedFiles = listAllTrackedFiles(['change/*'], repo.rootPath);
67+
const trackedFiles = listAllTrackedFiles({ patterns: ['change/*'], cwd: repo.rootPath });
6868
expect(cleanChangeFilePaths(repo.rootPath, trackedFiles)).toEqual(expectedFiles);
6969

7070
// and committed

src/__functional__/git/ensureSharedHistory.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('ensureSharedHistory', () => {
2828
const gitSpy = jest
2929
.spyOn(workspaceTools, 'git')
3030
// Attempt to force git to use English in logs, so we can check for absence of "warning" strings
31-
.mockImplementation((args, opts) => (gitOverride || realGit)(args, optsWithLang(opts)));
31+
.mockImplementation((args, opts) => (gitOverride || realGit)(args, opts && optsWithLang(opts)));
3232

3333
/**
3434
* Get git spy calls, by default ignoring rev-parse (does ref exist/is shallow repo?)

src/changefile/getChangedPackages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'path';
33
import minimatch from 'minimatch';
44
import type { ChangeFileInfo, ChangeInfoMultiple } from '../types/ChangeInfo';
55
import { getChangePath } from '../paths';
6-
import { getChanges, getStagedChanges, git } from 'workspace-tools';
6+
import { getBranchChanges, getStagedChanges, git } from 'workspace-tools';
77
import { getScopedPackages } from '../monorepo/getScopedPackages';
88
import type { BeachballOptions } from '../types/BeachballOptions';
99
import type { PackageInfos, PackageInfo } from '../types/PackageInfo';
@@ -78,7 +78,7 @@ function getAllChangedPackages(options: BeachballOptions, packageInfos: PackageI
7878
.map(pkg => pkg.name);
7979
}
8080

81-
const changes = [...(getChanges(branch, cwd) || []), ...(getStagedChanges(cwd) || [])];
81+
const changes = [...(getBranchChanges({ branch, cwd }) || []), ...(getStagedChanges({ cwd }) || [])];
8282
verboseLog(`Found ${count(changes.length, 'changed file')} in branch "${branch}" (before filtering)`);
8383

8484
if (!changes.length) {

src/changefile/readChangeFiles.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ export function readChangeFiles(options: BeachballOptions, packageInfos: Package
3131
let filteredChangeFiles = allChangeFiles;
3232

3333
if (fromRef) {
34-
const changeFilesSinceFromRef = getChangesBetweenRefs(
34+
const changeFilesSinceFromRef = getChangesBetweenRefs({
3535
fromRef,
36-
'HEAD',
37-
[
36+
toRef: 'HEAD',
37+
options: [
3838
'--diff-filter=d', // excluding deleted files from the diff.
3939
'--relative', // results will include path relative to the cwd, i.e. only file names.
4040
],
41-
'*.json',
42-
changePath
43-
);
41+
pattern: '*.json',
42+
cwd: changePath,
43+
});
4444

4545
filteredChangeFiles = allChangeFiles.filter(fileName => changeFilesSinceFromRef?.includes(fileName));
4646
}

src/changefile/writeChangeFiles.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function writeChangeFiles(
1616
): string[] {
1717
const { path: cwd, groupChanges, commit: commitChangeFiles } = options;
1818
const changePath = getChangePath(options);
19-
const branchName = getBranchName(cwd);
19+
const branchName = getBranchName({ cwd });
2020

2121
if (!(Object.keys(changes).length && branchName)) {
2222
return [];
@@ -43,11 +43,11 @@ export function writeChangeFiles(
4343
});
4444
}
4545

46-
stage(changeFiles, cwd);
46+
stage({ patterns: changeFiles, cwd });
4747
if (commitChangeFiles) {
4848
// only commit change files, ignore other staged files/changes
4949
const commitOptions = ['--only', path.join(changePath, '*.json')];
50-
commit('Change files', cwd, commitOptions);
50+
commit({ message: 'Change files', cwd, options: commitOptions });
5151
}
5252

5353
console.log(

src/changelog/getPackageChangelogs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function getPackageChangelogs(
3535

3636
if (includeCommitHashes) {
3737
changeFileCommits[changeFile] ??=
38-
getFileAddedHash(path.join(changePath, changeFile), options.path) || commitNotAvailable;
38+
getFileAddedHash({ filename: path.join(changePath, changeFile), cwd: options.path }) || commitNotAvailable;
3939
}
4040

4141
changelogs[packageName].comments ??= {};

0 commit comments

Comments
 (0)