Skip to content

Commit d01cbde

Browse files
authored
Fix GitHub repository provider when providing token with auth property (#6662)
1 parent d08a895 commit d01cbde

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

modules/nextflow/src/main/groovy/nextflow/scm/GithubRepositoryProvider.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ class GithubRepositoryProvider extends RepositoryProvider {
5555

5656
@Override
5757
String getUser() {
58-
super.getUser() ?: SysEnv.get('GITHUB_TOKEN')
58+
super.getUser() ?: getToken() ?: SysEnv.get('GITHUB_TOKEN')
5959
}
6060

6161
@Override
6262
String getPassword() {
63-
super.getPassword() ?: (SysEnv.containsKey('GITHUB_TOKEN') ? 'x-oauth-basic' : null)
63+
super.getPassword() ?: ( (getToken() || SysEnv.containsKey('GITHUB_TOKEN')) ? 'x-oauth-basic' : null)
6464
}
6565

6666
/** {@inheritDoc} */

modules/nextflow/src/test/groovy/nextflow/scm/GithubRepositoryProviderTest.groovy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,21 @@ class GithubRepositoryProviderTest extends Specification {
130130
SysEnv.pop()
131131
}
132132

133+
def 'should user specified token instead of github token as creds' () {
134+
given:
135+
SysEnv.push(['GITHUB_TOKEN': '1234567890'])
136+
and:
137+
def config = new ProviderConfig('github', [auth: '987654321'])
138+
def provider = Spy(new GithubRepositoryProvider('foo/bar', config))
139+
140+
expect:
141+
provider.getUser() == '987654321'
142+
provider.getPassword() == 'x-oauth-basic'
143+
144+
cleanup:
145+
SysEnv.pop()
146+
}
147+
133148
def 'should user from config' () {
134149
given:
135150
SysEnv.push(['GITHUB_TOKEN': '1234567890'])

0 commit comments

Comments
 (0)