Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
0980dca4
Commit
0980dca4
authored
Sep 25, 2014
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Command::Repo::List] Extract logic into helper methods
parent
b2c84dcd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
13 deletions
+55
-13
repo.rb
lib/cocoapods/command/repo.rb
+55
-13
No files found.
lib/cocoapods/command/repo.rb
View file @
0980dca4
...
...
@@ -196,11 +196,11 @@ module Pod
DESC
def
self
.
options
[[
"--count"
,
"Show the total number of repos"
]].
concat
(
super
)
[[
"--count
-only
"
,
"Show the total number of repos"
]].
concat
(
super
)
end
def
initialize
(
argv
)
@
should_count_number_of_repos
=
argv
.
flag?
(
'count
'
)
@
count_only
=
argv
.
flag?
(
'count-only
'
)
super
end
...
...
@@ -217,9 +217,20 @@ module Pod
#
def
run
sources
=
SourcesManager
.
all
sources
.
each
do
|
source
|
path
=
source
.
data_provider
.
repo
UI
.
title
source
.
name
do
print_sources
(
sources
)
unless
@count_only
print_count_of_sources
(
sources
)
end
private
# Pretty-prints the source at the given path.
#
# @param [String,Pathname] path
# The path of the source to be printed.
#
# @return [void]
#
def
print_source_at_path
(
path
)
Dir
.
chdir
(
path
)
do
if
SourcesManager
.
git_repo?
(
path
)
branch_name
=
get_branch_name
...
...
@@ -237,15 +248,39 @@ module Pod
UI
.
puts
"- Path:
#{
path
}
"
end
end
# Pretty-prints the given sources.
#
# @param [Array<Source>] sources
# The sources that should be printed.
#
# @return [void]
#
def
print_sources
(
sources
)
sources
.
each
do
|
source
|
UI
.
title
source
.
name
do
print_source_at_path
source
.
data_provider
.
repo
end
end
UI
.
puts
"
\n
"
end
if
@should_count_number_of_repos
# Pretty-prints the number of sources.
#
# @param [Array<Source>] sources
# The sources whose count should be printed.
#
# @return [void]
#
def
print_count_of_sources
(
sources
)
number_of_repos
=
sources
.
length
repo_string
=
number_of_repos
!=
1
?
'repos'
:
'repo'
UI
.
puts
"
\n
#{
number_of_repos
}
#{
repo_string
}
"
.
green
end
UI
.
puts
"
#{
number_of_repos
}
#{
repo_string
}
"
.
green
end
end
#-----------------------------------------------------------------------#
extend
Executable
executable
:git
...
...
@@ -253,26 +288,33 @@ module Pod
config
.
repos_dir
+
@name
end
# Returns the branch name (i.e. master)
# Returns the branch name (i.e. master).
#
# @return [String] The name of the current branch.
#
def
get_branch_name
`git name-rev --name-only HEAD`
.
strip
end
# Returns the branch remote name (i.e. origin)
# Returns the branch remote name (i.e. origin)
.
#
# @param [
BranchName
] branch_name
# @param [
#to_s
] branch_name
# The branch name to look for the remote name.
#
# @return [String] The given branch's remote name.
#
def
get_branch_remote_name
(
branch_name
)
`git config branch.
#{
branch_name
}
.remote`
.
strip
end
# Returns the url of the given remote name (i.e. git@github.com:CocoaPods/Specs.git)
# Returns the url of the given remote name
# (i.e. git@github.com:CocoaPods/Specs.git).
#
# @param [
RemoteName
] remote_name
# @param [
#to_s
] remote_name
# The branch remote name to look for the url.
#
# @return [String] The URL of the given remote.
#
def
get_url_of_git_repo
(
remote_name
)
`git config remote.
#{
remote_name
}
.url`
.
strip
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment