1.1pre1
This commit is contained in:
parent
3a2b273316
commit
6b030fd41d
83 changed files with 1089 additions and 136 deletions
|
@ -11,6 +11,10 @@ module Color
|
|||
colorize(text, "32m")
|
||||
end
|
||||
|
||||
def yellow(text)
|
||||
colorize(text, "93m")
|
||||
end
|
||||
|
||||
def command(string)
|
||||
`#{string}`
|
||||
if $?.to_i > 0
|
||||
|
|
|
@ -27,13 +27,11 @@ class Gitosis
|
|||
def configure
|
||||
status = Timeout::timeout(20) do
|
||||
File.open(File.join(Dir.tmpdir,"gitlabhq-gitosis.lock"), "w+") do |f|
|
||||
begin
|
||||
begin
|
||||
f.flock(File::LOCK_EX)
|
||||
|
||||
pull
|
||||
yield(self)
|
||||
push
|
||||
|
||||
ensure
|
||||
f.flock(File::LOCK_UN)
|
||||
end
|
||||
|
|
51
lib/utils.rb
51
lib/utils.rb
|
@ -1,8 +1,51 @@
|
|||
module Utils
|
||||
def self.binary?(string)
|
||||
string.each_byte do |x|
|
||||
x.nonzero? or return true
|
||||
module FileHelper
|
||||
def binary?(string)
|
||||
string.each_byte do |x|
|
||||
x.nonzero? or return true
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def image?
|
||||
mime_type =~ /image/
|
||||
end
|
||||
|
||||
def text?
|
||||
mime_type =~ /application|text/ && !binary?(data)
|
||||
end
|
||||
end
|
||||
|
||||
module Colorize
|
||||
def colorize
|
||||
system_colorize(data, name)
|
||||
end
|
||||
|
||||
def system_colorize(data, file_name)
|
||||
ft = handle_file_type(file_name)
|
||||
Pygments.highlight(data, :lexer => ft, :options => { :encoding => 'utf-8', :linenos => 'True' })
|
||||
end
|
||||
|
||||
def handle_file_type(file_name, mime_type = nil)
|
||||
if file_name =~ /(\.rb|\.ru|\.rake|Rakefile|\.gemspec|\.rbx|Gemfile)$/
|
||||
:ruby
|
||||
elsif file_name =~ /\.py$/
|
||||
:python
|
||||
elsif file_name =~ /(\.pl|\.scala|\.c|\.cpp|\.java|\.haml|\.html|\.sass|\.scss|\.xml|\.php|\.erb)$/
|
||||
$1[1..-1].to_sym
|
||||
elsif file_name =~ /\.js$/
|
||||
:javascript
|
||||
elsif file_name =~ /\.sh$/
|
||||
:bash
|
||||
elsif file_name =~ /\.coffee$/
|
||||
:coffeescript
|
||||
elsif file_name =~ /\.yml$/
|
||||
:yaml
|
||||
elsif file_name =~ /\.md$/
|
||||
:minid
|
||||
else
|
||||
:text
|
||||
end
|
||||
end
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue