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

Commit 9f86d28

Browse files
committed
fix - Assets are uploaded as 34 byte
1 parent cc5f6ee commit 9f86d28

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-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

+31-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,34 @@ 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(
81+
path.join(__dirname, 'assets', 'LICENSE'),
82+
'utf8',
83+
);
84+
const jarFile = fs.readFileSync(
85+
path.join(__dirname, 'assets', 'test.jar'),
86+
'utf8',
87+
);
88+
89+
const args = [{
90+
repoToken: 'repoToken',
91+
automaticReleaseTag: 'automaticReleaseTag',
92+
draftRelease: false,
93+
preRelease: false,
94+
releaseTitle: 'releaseTitle',
95+
file: licenseFile
96+
}, {
97+
repoToken: 'repoToken',
98+
automaticReleaseTag: 'automaticReleaseTag',
99+
draftRelease: false,
100+
preRelease: false,
101+
releaseTitle: 'releaseTitle',
102+
file: jarFile
103+
}];
104+
105+
expect(args[0].file).toEqual('this should not be overridden');
106+
expect(args[1].file).toEqual('');
107+
});
78108
});

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)