Skip to content

Commit

Permalink
Reject saving private repositories #481
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Apr 2, 2024
1 parent 7da01b5 commit dbed97f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/hosts/bitbucket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def fetch_repository(full_name)
resp = api_client.get("/2.0/repositories/#{user_name}/#{repo_name.downcase}")
return nil unless resp.success?
project = resp.body
return nil if project['is_private']
repo_hash = project.to_hash.with_indifferent_access.slice(:description, :uuid, :language, :full_name, :has_wiki, :has_issues, :scm)

repo_hash.merge!({
Expand Down
1 change: 1 addition & 0 deletions app/models/hosts/gitea.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def fetch_repository(id_or_name)
end
resp = api_client.get(url)
return nil unless resp.success? && resp.body.present?
return nil if resp.body['private']
map_repository_data(resp.body)
end

Expand Down
1 change: 1 addition & 0 deletions app/models/hosts/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def topic_url(topic)
def fetch_repository(id_or_name)
id_or_name = id_or_name.to_i if id_or_name.match(/\A\d+\Z/)
hash = api_client.repo(id_or_name, accept: 'application/vnd.github.drax-preview+json,application/vnd.github.mercy-preview+json').to_hash.with_indifferent_access
return nil if hash[:private]
map_repository_data(hash)
end

Expand Down
2 changes: 2 additions & 0 deletions app/models/hosts/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def api_client

def fetch_repository(full_name)
project = api_client.project(full_name, license: true)
return nil if project.visibility != "public"

repo_hash = project.to_hash.with_indifferent_access.slice(:id, :description, :created_at, :name, :open_issues_count, :forks_count, :default_branch, :archived, :topics)

repo_hash.merge!({
Expand Down

0 comments on commit dbed97f

Please sign in to comment.