Extract task helper methods
This commit is contained in:
parent
9655350c79
commit
224da71177
3 changed files with 39 additions and 63 deletions
|
@ -80,31 +80,5 @@ namespace :gitlab do
|
|||
puts "Git:\t\t#{Gitlab.config.git.bin_path}"
|
||||
|
||||
end
|
||||
|
||||
|
||||
# Helper methods
|
||||
|
||||
# Runs the given command and matches the output agains the given pattern
|
||||
#
|
||||
# Returns nil if nothing matched
|
||||
# Retunrs the MatchData if the pattern matched
|
||||
#
|
||||
# see also #run
|
||||
# see also String#match
|
||||
def run_and_match(command, regexp)
|
||||
run(command).try(:match, regexp)
|
||||
end
|
||||
|
||||
# Runs the given command
|
||||
#
|
||||
# Returns nil if the command was not found
|
||||
# Returns the output of the command otherwise
|
||||
#
|
||||
# see also #run_and_match
|
||||
def run(command)
|
||||
unless `#{command} 2>/dev/null`.blank?
|
||||
`#{command}`
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue