Skip to content

Commit 711390f

Browse files
authored
fix(3415): Do not treat "internal" repo as "private" (#252)
1 parent 8c5e0ab commit 711390f

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ class GithubScm extends Scm {
308308

309309
repoFullName = repo.data.full_name;
310310
defaultBranch = repo.data.default_branch;
311-
privateRepo = repo.data.private;
311+
privateRepo = repo.data.private && repo.data.visibility === 'private';
312312
} catch (err) {
313313
logger.error('Failed to lookupScmUri: ', err);
314314
throw err;

test/index.test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,6 +2584,66 @@ jobs:
25842584
});
25852585
});
25862586

2587+
it('decorates a scm uri associated with a private repo', () => {
2588+
const scmUri = 'github.com:102498:boat!"#$%&\'()-=|@`{;+]},<.>/ 🚗';
2589+
2590+
githubMock.request.resolves({
2591+
data: {
2592+
full_name: 'iAm/theCaptain',
2593+
private: true,
2594+
visibility: 'private'
2595+
}
2596+
});
2597+
2598+
return scm
2599+
.decorateUrl({
2600+
scmUri,
2601+
token: 'mytokenfortesting'
2602+
})
2603+
.then(data => {
2604+
assert.deepEqual(data, {
2605+
branch: 'boat!"#$%&\'()-=|@`{;+]},<.>/ 🚗',
2606+
name: 'iAm/theCaptain',
2607+
url: `https://github.com/iAm/theCaptain/tree/${encodeURIComponent(
2608+
'boat!"#$%&\'()-=|@`{;+]},<.>/ 🚗'
2609+
)}`,
2610+
rootDir: '',
2611+
private: true
2612+
});
2613+
assert.calledWith(githubMock.request, 'GET /repositories/:id', { id: '102498' });
2614+
});
2615+
});
2616+
2617+
it('decorates a scm uri associated with an internal repo', () => {
2618+
const scmUri = 'github.com:102498:boat!"#$%&\'()-=|@`{;+]},<.>/ 🚗';
2619+
2620+
githubMock.request.resolves({
2621+
data: {
2622+
full_name: 'iAm/theCaptain',
2623+
private: true,
2624+
visibility: 'internal'
2625+
}
2626+
});
2627+
2628+
return scm
2629+
.decorateUrl({
2630+
scmUri,
2631+
token: 'mytokenfortesting'
2632+
})
2633+
.then(data => {
2634+
assert.deepEqual(data, {
2635+
branch: 'boat!"#$%&\'()-=|@`{;+]},<.>/ 🚗',
2636+
name: 'iAm/theCaptain',
2637+
url: `https://github.com/iAm/theCaptain/tree/${encodeURIComponent(
2638+
'boat!"#$%&\'()-=|@`{;+]},<.>/ 🚗'
2639+
)}`,
2640+
rootDir: '',
2641+
private: false
2642+
});
2643+
assert.calledWith(githubMock.request, 'GET /repositories/:id', { id: '102498' });
2644+
});
2645+
});
2646+
25872647
it('decorates a scm uri with rootDir', () => {
25882648
const scmUri = 'github.com:102498:boat!"#$%&\'()-=|@`{;+]},<.>/ 🚗:src/app/component';
25892649

0 commit comments

Comments
 (0)