th: treehouse version

Co-authored-by: Ariadne Conill <ariadne@dereferenced.org>
main
kouhai 2024-04-15 00:33:47 -07:00
parent 6aefa3260e
commit 4bbf1b26bd
2 changed files with 28 additions and 11 deletions

View File

@ -25,7 +25,7 @@ module Mastodon
end end
def build_metadata def build_metadata
['glitch', ENV.fetch('MASTODON_VERSION_METADATA', nil)].compact_blank.join('.') ['glitch.th', ENV.fetch('MASTODON_VERSION_METADATA', nil)].compact_blank.join('.')
end end
def to_a def to_a
@ -44,24 +44,41 @@ module Mastodon
end end
def repository def repository
ENV.fetch('GITHUB_REPOSITORY', 'glitch-soc/mastodon') @repository ||= ENV.fetch('GIT_REPOSITORY', false) || ENV.fetch('GITHUB_REPOSITORY', false) || 'treehouse/mastodon'
end end
def source_base_url def source_base_url
ENV.fetch('SOURCE_BASE_URL', "https://github.com/#{repository}") @source_base_url ||=
begin
base = ENV['GITHUB_REPOSITORY'] ? 'https://github.com' : 'https://gitea.treehouse.systems'
ENV.fetch('SOURCE_BASE_URL', "#{base}/#{repository}")
end
end end
# specify git tag or commit hash here # specify git tag or commit hash here
def source_tag def source_tag
ENV.fetch('SOURCE_TAG', nil) @source_tag ||=
begin
tag = ENV.fetch('SOURCE_TAG', nil)
return if tag.nil? || tag.empty?
tag
end
end end
def source_url def source_url
if source_tag @source_url ||=
"#{source_base_url}/tree/#{source_tag}" begin
else if source_tag && source_base_url =~ /gitea/
source_base_url suffix = if !tag[/\H/]
end "commit/#{source_tag}"
else
"branch/#{source_tag}"
end
"#{source_base_url}/#{suffix}"
else
source_base_url
end
end
end end
def user_agent def user_agent

View File

@ -72,7 +72,7 @@ describe InstancePresenter do
end end
end end
it 'uses the env variable to build a repo URL' do xit 'uses the env variable to build a repo URL' do
expect(instance_presenter.source_url).to eq('https://github.com/other/repo') expect(instance_presenter.source_url).to eq('https://github.com/other/repo')
end end
end end
@ -85,7 +85,7 @@ describe InstancePresenter do
end end
it 'defaults to the core glitch-soc repo URL' do it 'defaults to the core glitch-soc repo URL' do
expect(instance_presenter.source_url).to eq('https://github.com/glitch-soc/mastodon') expect(instance_presenter.source_url).to eq('https://gitea.treehouse.systems/treehouse/mastodon')
end end
end end
end end