mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-16 17:55:56 +08:00
add: name query for branches
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
class Branches::ListService < ApplicationService
|
||||
|
||||
attr_reader :user, :project
|
||||
attr_reader :user, :project, :name
|
||||
|
||||
def initialize(user, project)
|
||||
def initialize(user, project, name=nil)
|
||||
@user = user
|
||||
@project = project
|
||||
@name = name
|
||||
end
|
||||
|
||||
def call
|
||||
all_branches = []
|
||||
user_name = user.try(:show_real_name)
|
||||
identifier = project.repository.try(:identifier)
|
||||
get_all_branches = Gitea::Repository::Branches::ListService.new(user, identifier).call
|
||||
get_all_branches = Gitea::Repository::Branches::ListService.new(user, identifier, name).call
|
||||
all_branches = branch_lists(user_name,user.try(:login), identifier, get_all_branches) if get_all_branches && get_all_branches.size > 0
|
||||
return all_branches
|
||||
end
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
class Gitea::Repository::Branches::ListNameService < Gitea::ClientService
|
||||
attr_reader :user, :repo
|
||||
attr_reader :user, :repo, :name
|
||||
|
||||
def initialize(user, repo)
|
||||
def initialize(user, repo, name=nil)
|
||||
@user = user
|
||||
@repo = repo
|
||||
@name = name
|
||||
end
|
||||
|
||||
def call
|
||||
@@ -13,7 +14,7 @@ class Gitea::Repository::Branches::ListNameService < Gitea::ClientService
|
||||
|
||||
private
|
||||
def params
|
||||
Hash.new.merge(token: user.gitea_token)
|
||||
Hash.new.merge(token: user.gitea_token, name: name)
|
||||
end
|
||||
|
||||
def url
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
class Gitea::Repository::Branches::ListService < Gitea::ClientService
|
||||
attr_reader :user, :repo
|
||||
attr_reader :user, :repo, :name
|
||||
|
||||
def initialize(user, repo)
|
||||
def initialize(user, repo, name=nil)
|
||||
@user = user
|
||||
@repo = repo
|
||||
@name = name
|
||||
end
|
||||
|
||||
def call
|
||||
@@ -13,7 +14,7 @@ class Gitea::Repository::Branches::ListService < Gitea::ClientService
|
||||
|
||||
private
|
||||
def params
|
||||
Hash.new.merge(token: user.gitea_token)
|
||||
Hash.new.merge(token: user.gitea_token, name: name)
|
||||
end
|
||||
|
||||
def url
|
||||
|
||||
Reference in New Issue
Block a user