add: name query for branches

This commit is contained in:
2022-04-26 17:15:59 +08:00
parent fc3cf01d3f
commit 088c617cc1
6 changed files with 16 additions and 13 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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