Skip to content

Commit

Permalink
Add support for template repositories #437
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Jan 16, 2024
1 parent 90f5f7e commit bf00892
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/models/hosts/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def repository_columns
:scm,
:status,
:source_name,
:template,
:template_full_name
# :allow_forking,
# :has_projects,
# :has_downloads,
Expand Down
3 changes: 2 additions & 1 deletion app/models/hosts/gitea.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ def map_repository_data(data)
logo_url: data['avatar_url'].presence || data['owner']['avatar_url'],
topics: fetch_topics(data['full_name']),
created_at: data['created_at'],
updated_at: data['updated_at']
updated_at: data['updated_at'],
template: data['template'],
}
end

Expand Down
2 changes: 2 additions & 0 deletions app/models/hosts/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def map_repository_data(hash)
hash[:license] = hash[:license][:key] if hash[:license]
hash[:owner] = hash[:owner][:login]
hash[:pull_requests_enabled] = true
hash[:template]= hash[:is_template]
hash[:template_full_name] = hash[:template_repository][:full_name] if hash[:template_repository]

if hash[:fork] && hash[:parent]
hash[:source_name] = hash[:parent][:full_name]
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/v1/repositories/_repository.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
json.extract! repository, :uuid, :full_name, :owner, :description, :archived, :fork, :pushed_at, :size, :stargazers_count, :open_issues_count,
:forks_count, :subscribers_count, :default_branch, :last_synced_at, :etag, :topics, :latest_commit_sha, :homepage, :language, :has_issues,
:has_wiki, :has_pages, :mirror_url, :source_name, :license, :status, :scm, :pull_requests_enabled, :icon_url, :metadata, :created_at, :updated_at,
:dependencies_parsed_at, :dependency_job_id, :html_url, :commit_stats, :previous_names, :tags_count
:dependencies_parsed_at, :dependency_job_id, :html_url, :commit_stats, :previous_names, :tags_count, :template, :template_full_name

json.repository_url api_v1_host_repository_url(repository.host, repository)
json.tags_url api_v1_host_repository_tags_url(repository.host, repository)
Expand Down
6 changes: 6 additions & 0 deletions db/migrate/20240116161040_add_template_to_repositories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddTemplateToRepositories < ActiveRecord::Migration[7.1]
def change
add_column :repositories, :template, :boolean
add_column :repositories, :template_full_name, :string
end
end
4 changes: 3 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions openapi/api/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,10 @@ components:
type: string
tags_count:
type: integer
template:
type: boolean
template_full_name:
type: string
latest_tag_name:
type: string
latest_tag_published_at:
Expand Down

0 comments on commit bf00892

Please sign in to comment.