mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-24 05:35:46 +08:00
Update get branches api
This commit is contained in:
@@ -428,7 +428,7 @@ class IssuesController < ApplicationController
|
|||||||
|
|
||||||
def get_branches
|
def get_branches
|
||||||
all_branches = []
|
all_branches = []
|
||||||
get_all_branches = Gitea::Repository::BranchesService.new(@user, @project&.repository.try(:identifier)).call
|
get_all_branches = Gitea::Repository::Branches::ListService.new(@user, @project&.repository.try(:identifier)).call
|
||||||
if get_all_branches && get_all_branches.size > 0
|
if get_all_branches && get_all_branches.size > 0
|
||||||
get_all_branches.each do |b|
|
get_all_branches.each do |b|
|
||||||
all_branches.push(b["name"])
|
all_branches.push(b["name"])
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class ProjectsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def branches
|
def branches
|
||||||
@branches = Gitea::Repository::BranchesService.new(@project.owner, @project.identifier).call
|
@branches = Gitea::Repository::Branches::ListService.new(@project.owner, @project.identifier).call
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_type_list
|
def group_type_list
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class PullRequestsController < ApplicationController
|
|||||||
|
|
||||||
def new
|
def new
|
||||||
@all_branches = []
|
@all_branches = []
|
||||||
get_all_branches = Gitea::Repository::BranchesService.new(@user, @repository.try(:identifier)).call
|
get_all_branches = Gitea::Repository::Branches::ListService.new(@user, @repository.try(:identifier)).call
|
||||||
if get_all_branches && get_all_branches.size > 0
|
if get_all_branches && get_all_branches.size > 0
|
||||||
get_all_branches.each do |b|
|
get_all_branches.each do |b|
|
||||||
@all_branches.push(b["name"])
|
@all_branches.push(b["name"])
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class VersionReleasesController < ApplicationController
|
|||||||
def new
|
def new
|
||||||
#获取所有的分支
|
#获取所有的分支
|
||||||
@all_branches = []
|
@all_branches = []
|
||||||
get_all_branches = Gitea::Repository::BranchesService.new(@user, @repository.try(:identifier)).call
|
get_all_branches = Gitea::Repository::Branches::ListService.new(@user, @repository.try(:identifier)).call
|
||||||
if get_all_branches && get_all_branches.size > 0
|
if get_all_branches && get_all_branches.size > 0
|
||||||
get_all_branches.each do |b|
|
get_all_branches.each do |b|
|
||||||
@all_branches.push(b["name"])
|
@all_branches.push(b["name"])
|
||||||
|
|||||||
27
app/services/gitea/repository/branches/get_service.rb
Normal file
27
app/services/gitea/repository/branches/get_service.rb
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Retrieve a specific branch from a repository, including its effective branch protection
|
||||||
|
class Gitea::Repository::Branches::GetService < Gitea::ClientService
|
||||||
|
attr_reader :owner, :repo, :branch, :token
|
||||||
|
|
||||||
|
# ex:
|
||||||
|
# Gitea::Repository::Branches::GetService.new(@project.owner, @project.identifier, 'master', current_user.gitea_token).call
|
||||||
|
def initialize(owner, repo, branch, token)
|
||||||
|
@owner = owner
|
||||||
|
@repo = repo
|
||||||
|
@branch = branch
|
||||||
|
@token = token
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
response = get(url, params)
|
||||||
|
render_data(response)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def params
|
||||||
|
Hash.new.merge(token: token)
|
||||||
|
end
|
||||||
|
|
||||||
|
def url
|
||||||
|
"/repos/#{owner}/#{repo}/branches/#{branch}".freeze
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
class Gitea::Repository::BranchesService < Gitea::ClientService
|
class Gitea::Repository::Branches::ListService < Gitea::ClientService
|
||||||
attr_reader :user, :repo
|
attr_reader :user, :repo
|
||||||
|
|
||||||
def initialize(user, repo)
|
def initialize(user, repo)
|
||||||
Reference in New Issue
Block a user