Skip to content

Commit

Permalink
fix: ensure windows releases include build number (#2746)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanoltman authored Jan 9, 2025
1 parent 691cd0a commit b946e89
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
6 changes: 5 additions & 1 deletion packages/shorebird_cli/lib/src/executables/powershell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class Powershell {
runInShell: true,
);

return (result.stdout as String).trim();
var versionString = (result.stdout as String).trim();
if (!versionString.contains('+')) {
versionString += '+0';
}
return versionString;
}
}
33 changes: 25 additions & 8 deletions packages/shorebird_cli/test/src/executables/powershell_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,33 @@ void main() {
});

group('when exit code is success', () {
setUp(() {
when(() => processResult.exitCode).thenReturn(0);
when(() => processResult.stdout).thenReturn('1.0.0');
group('when version code includes a build number', () {
setUp(() {
when(() => processResult.exitCode).thenReturn(0);
when(() => processResult.stdout).thenReturn('1.0.0+1');
});

test('returns unaltered version string', () async {
final version = await runWithOverrides(
() => powershell.getExeVersionString(File('')),
);
expect(version, '1.0.0+1');
});
});

test('returns the version string', () async {
final version = await runWithOverrides(
() => powershell.getExeVersionString(File('')),
);
expect(version, '1.0.0');
group('when version code does not include a build number', () {
setUp(() {
when(() => processResult.exitCode).thenReturn(0);
when(() => processResult.stdout).thenReturn('1.0.0');
});

test('returns the version string with build number 0 added',
() async {
final version = await runWithOverrides(
() => powershell.getExeVersionString(File('')),
);
expect(version, '1.0.0+0');
});
});
});
});
Expand Down

0 comments on commit b946e89

Please sign in to comment.