Skip to content

feat: Updated Gitea ProviderConfig server default #6285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ProviderConfig {

case 'gitea':
attr.platform = name
if( !attr.server ) attr.server = 'https://try.gitea.io'
if( !attr.server ) attr.server = 'https://gitea.com' // default to free tier
if( !attr.endpoint ) attr.endpoint = attr.server.toString().stripEnd('/') + '/api/v1'
break

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,25 @@ import spock.lang.Specification
*/
class GiteaRepositoryProviderTest extends Specification {

static final String CONFIG = '''
providers {
mygitea {
server = 'https://gitea.com'
endpoint = 'https://gitea.com/api/v1'
platform = 'gitea'
}
}
'''

def 'should return repo url' () {
given:
def config = new ConfigSlurper().parse(CONFIG)
def obj = new ProviderConfig('gitea', config.providers.mygitea as ConfigObject)
def obj = new ProviderConfig('gitea')

expect:
new GiteaRepositoryProvider('pditommaso/hello', obj).getEndpointUrl() == 'https://gitea.com/api/v1/repos/pditommaso/hello'
}

def 'should return project URL' () {
given:
def config = new ConfigSlurper().parse(CONFIG)
def obj = new ProviderConfig('gitea', config.providers.mygitea as ConfigObject)
def obj = new ProviderConfig('gitea')

expect:
new GiteaRepositoryProvider('pditommaso/hello', obj).getRepositoryUrl() == 'https://gitea.com/pditommaso/hello'
}

def 'should return content URL' () {
given:
def config = new ConfigSlurper().parse(CONFIG)
def obj = new ProviderConfig('gitea', config.providers.mygitea as ConfigObject)
def obj = new ProviderConfig('gitea')

expect:
new GiteaRepositoryProvider('pditommaso/hello', obj)
Expand All @@ -73,7 +60,7 @@ class GiteaRepositoryProviderTest extends Specification {
def 'should read file content'() {
given:
def token = System.getenv('NXF_GITEA_ACCESS_TOKEN')
def config = new ProviderConfig('gitea', new ConfigSlurper().parse(CONFIG).providers.mygitea as ConfigObject) .setAuth(token)
def config = new ProviderConfig('gitea') .setAuth(token)

when:
def repo = new GiteaRepositoryProvider('pditommaso/test-hello', config)
Expand All @@ -94,7 +81,7 @@ class GiteaRepositoryProviderTest extends Specification {
def 'should read bytes gitea content'() {
given:
def token = System.getenv('NXF_GITEA_ACCESS_TOKEN')
def config = new ProviderConfig('gitea', new ConfigSlurper().parse(CONFIG).providers.mygitea as ConfigObject) .setAuth(token)
def config = new ProviderConfig('gitea') .setAuth(token)
def repo = new GiteaRepositoryProvider('pditommaso/test-hello', config)
and:
def DATA = this.class.getResourceAsStream('/test-asset.bin').bytes
Expand All @@ -111,7 +98,7 @@ class GiteaRepositoryProviderTest extends Specification {
def 'should read bytes file content'() {
given:
def token = System.getenv('NXF_GITEA_ACCESS_TOKEN')
def config = new ProviderConfig('gitea', new ConfigSlurper().parse(CONFIG).providers.mygitea as ConfigObject).setAuth(token)
def config = new ProviderConfig('gitea').setAuth(token)

when:
def repo = new GiteaRepositoryProvider('pditommaso/test-hello', config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ class ProviderConfigTest extends Specification {
config.user == null
config.password == null
config.token == 'xyz'

when:
config = new ProviderConfig('gitea', [auth: 'xyz'])
then:
config.auth == null
config.user == null
config.password == null
config.token == 'xyz'
config.server == 'https://gitea.com'
config.endpoint == 'https://gitea.com/api/v1'
}

def 'should ending slash and add protocol prefix' () {
Expand Down