mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
fix: issue edit and new branches only load name api
This commit is contained in:
@@ -29,8 +29,9 @@ module TagChosenHelper
|
||||
if project.educoder?
|
||||
return ['master']
|
||||
else
|
||||
branches = Gitea::Repository::Branches::ListService.call(project&.owner, project.identifier)
|
||||
branches.collect{|i| i["name"] if i.is_a?(Hash)}
|
||||
branches = Gitea::Repository::Branches::ListNameService.call(project&.owner, project.identifier)
|
||||
return branches.collect{|i| i["name"] if i.is_a?(Hash)} if branches.is_a?(Array)
|
||||
return branches["branch_name"] if branches.is_a?(Hash)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
22
app/services/gitea/repository/branches/list_name_service.rb
Normal file
22
app/services/gitea/repository/branches/list_name_service.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
class Gitea::Repository::Branches::ListNameService < Gitea::ClientService
|
||||
attr_reader :user, :repo
|
||||
|
||||
def initialize(user, repo)
|
||||
@user = user
|
||||
@repo = repo
|
||||
end
|
||||
|
||||
def call
|
||||
response = get(url, params)
|
||||
render_200_response(response)
|
||||
end
|
||||
|
||||
private
|
||||
def params
|
||||
Hash.new.merge(token: user.gitea_token)
|
||||
end
|
||||
|
||||
def url
|
||||
"/repos/#{user.login}/#{repo}/branch_name_set".freeze
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user