Skip to content
This repository was archived by the owner on May 5, 2024. It is now read-only.

Commit 3e804da

Browse files
committed
fix: Assets are uploaded as 34 byte
1 parent cc5f6ee commit 3e804da

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
this should not be overridden

packages/automatic-releases/__tests__/assets/test.jar

Whitespace-only changes.

packages/automatic-releases/__tests__/utils.test.ts

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from 'path';
22
import fs from 'fs';
3-
import {generateChangelogFromParsedCommits} from '../src/utils';
3+
import {generateChangelogFromParsedCommits, octokitLogger} from '../src/utils';
44

55
describe('changelog generator', () => {
66
beforeEach(() => {
@@ -75,4 +75,33 @@ describe('changelog generator', () => {
7575
const result = generateChangelogFromParsedCommits(payload);
7676
expect(result.trim()).toEqual(expected.trim());
7777
});
78+
79+
it('log of input arguments should not overwrite the original args', () => {
80+
const licenseFile = fs.readFileSync(path.join(__dirname, 'assets', 'LICENSE'), 'utf8');
81+
const jarFile = fs.readFileSync(path.join(__dirname, 'assets', 'test.jar'), 'utf8');
82+
83+
const args = [
84+
{
85+
repoToken: 'repoToken',
86+
automaticReleaseTag: 'automaticReleaseTag',
87+
draftRelease: false,
88+
preRelease: false,
89+
releaseTitle: 'releaseTitle',
90+
file: licenseFile,
91+
},
92+
{
93+
repoToken: 'repoToken',
94+
automaticReleaseTag: 'automaticReleaseTag',
95+
draftRelease: false,
96+
preRelease: false,
97+
releaseTitle: 'releaseTitle',
98+
file: jarFile,
99+
},
100+
];
101+
102+
octokitLogger(...args);
103+
104+
expect(args[0].file).toEqual('this should not be overridden');
105+
expect(args[1].file).toEqual('');
106+
});
78107
});

packages/automatic-releases/src/utils.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,17 @@ export const octokitLogger = (...args): string => {
168168
return arg;
169169
}
170170

171+
const argCopy = {...arg};
172+
171173
// Do not log file buffers
172-
if (arg.file) {
173-
arg.file = '== raw file buffer info removed ==';
174+
if (argCopy.file) {
175+
argCopy.file = '== raw file buffer info removed ==';
174176
}
175-
if (arg.data) {
176-
arg.data = '== raw file buffer info removed ==';
177+
if (argCopy.data) {
178+
argCopy.data = '== raw file buffer info removed ==';
177179
}
178180

179-
return JSON.stringify(arg);
181+
return JSON.stringify(argCopy);
180182
})
181183
.reduce((acc, val) => `${acc} ${val}`, '');
182184
};

0 commit comments

Comments
 (0)