Skip to content

Commit

Permalink
Add translation edit and rename translation to new translation
Browse files Browse the repository at this point in the history
Closes #42
  • Loading branch information
sebastiaanspeck committed Dec 30, 2024
1 parent 1febabf commit c324e1f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 13 deletions.
29 changes: 24 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2758,7 +2758,7 @@ class HttpClient {
}
const usingSsl = parsedUrl.protocol === 'https:';
proxyAgent = new undici_1.ProxyAgent(Object.assign({ uri: proxyUrl.href, pipelining: !this._keepAlive ? 0 : 1 }, ((proxyUrl.username || proxyUrl.password) && {
token: `${proxyUrl.username}:${proxyUrl.password}`
token: `Basic ${Buffer.from(`${proxyUrl.username}:${proxyUrl.password}`).toString('base64')}`
})));
this._proxyAgentDispatcher = proxyAgent;
if (usingSsl && this._ignoreSslError) {
Expand Down Expand Up @@ -2872,11 +2872,11 @@ function getProxyUrl(reqUrl) {
})();
if (proxyVar) {
try {
return new URL(proxyVar);
return new DecodedURL(proxyVar);
}
catch (_a) {
if (!proxyVar.startsWith('http://') && !proxyVar.startsWith('https://'))
return new URL(`http://${proxyVar}`);
return new DecodedURL(`http://${proxyVar}`);
}
}
else {
Expand Down Expand Up @@ -2935,6 +2935,19 @@ function isLoopbackAddress(host) {
hostLower.startsWith('[::1]') ||
hostLower.startsWith('[0:0:0:0:0:0:0:1]'));
}
class DecodedURL extends URL {
constructor(url, base) {
super(url, base);
this._decodedUsername = decodeURIComponent(super.username);
this._decodedPassword = decodeURIComponent(super.password);
}
get username() {
return this._decodedUsername;
}
get password() {
return this._decodedPassword;
}
}
//# sourceMappingURL=proxy.js.map

/***/ }),
Expand Down Expand Up @@ -29919,7 +29932,8 @@ var LabelType;
LabelType["newCommand"] = "new command";
LabelType["pageEdit"] = "page edit";
LabelType["tooling"] = "tooling";
LabelType["translation"] = "translation";
LabelType["newTranslation"] = "new translation";
LabelType["translationEdit"] = "translation edit";
LabelType["waiting"] = "waiting";
})(LabelType || (exports.LabelType = LabelType = {}));
const communityRegex = /^MAINTAINERS\.md$|^\.github\/CODEOWNERS$/;
Expand Down Expand Up @@ -29970,7 +29984,12 @@ const getFileLabel = (file) => {
}
}
if (translationPageRegex.test(file.filename) || (file.previous_filename && translationPageRegex.test(file.previous_filename))) {
return LabelType.translation;
if (file.status === FileStatus.added) {
return LabelType.newTranslation;
}
if ([FileStatus.modified, FileStatus.removed, FileStatus.renamed].includes(file.status)) {
return LabelType.translationEdit;
}
}
if (communityRegex.test(file.filename) || (file.previous_filename && communityRegex.test(file.previous_filename))) {
return LabelType.community;
Expand Down
16 changes: 12 additions & 4 deletions src/labeler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,25 @@ describe('getFileLabel', () => {
});

describe('when a translation page is changed', () => {
describe('and the status is added', () => {
it('should return new command label', () => {
expect(getFileLabel({
filename: 'pages.de/common/git.md',
status: FileStatus.added,
})).toBe(LabelType.newTranslation);
});
});

describe.each([
FileStatus.added,
FileStatus.modified,
FileStatus.removed,
FileStatus.renamed
FileStatus.renamed,
])('and the status is %s', (status: FileStatus) => {
it('should return translation label', () => {
it('should return translation edit label', () => {
expect(getFileLabel({
filename: 'pages.de/common/git.md',
status,
})).toBe(LabelType.translation);
})).toBe(LabelType.translationEdit);
});
});
});
Expand Down
10 changes: 8 additions & 2 deletions src/labeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export enum LabelType {
newCommand = 'new command',
pageEdit = 'page edit',
tooling = 'tooling',
translation = 'translation',
newTranslation = 'new translation',
translationEdit = 'translation edit',
waiting = 'waiting',
}

Expand Down Expand Up @@ -105,7 +106,12 @@ export const getFileLabel = (file: PrFile): string|null => {
}
}
if (translationPageRegex.test(file.filename) || (file.previous_filename && translationPageRegex.test(file.previous_filename))) {
return LabelType.translation;
if (file.status === FileStatus.added) {
return LabelType.newTranslation;
}
if ([FileStatus.modified, FileStatus.removed, FileStatus.renamed].includes(file.status)) {
return LabelType.translationEdit;
}
}
if (communityRegex.test(file.filename) || (file.previous_filename && communityRegex.test(file.previous_filename))) {
return LabelType.community;
Expand Down
4 changes: 2 additions & 2 deletions src/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {uniq} from './util';

describe('uniq', () => {
it('should return an array with unique values', () => {
const unique = uniq([LabelType.newCommand, LabelType.newCommand, LabelType.translation]);
expect(unique).toEqual([LabelType.newCommand, LabelType.translation]);
const unique = uniq([LabelType.newCommand, LabelType.newCommand, LabelType.newTranslation]);
expect(unique).toEqual([LabelType.newCommand, LabelType.newTranslation]);
});
});

0 comments on commit c324e1f

Please sign in to comment.