Sha256: 86c24e4df34ed1f650b7a1e86804930fb144067eb3a8ae784bd224748b014c2d

Contents?: true

Size: 870 Bytes

Versions: 37

Compression:

Stored size: 870 Bytes

Contents

require 'socket'

module OhlohScm::Adapters
	class GitAdapter < AbstractAdapter

		COMMITTER_NAME = 'ohloh_slave' unless defined?(COMMITTER_NAME)

		def push(to)
			logger.info { "Pushing to #{to.url}" }

			if to.exist?
				ENV['GIT_COMMITTER_NAME'] = COMMITTER_NAME
				run "cd '#{self.url}' && git push '#{to.url}' #{self.branch_name}:#{to.branch_name}"
			else
				if to.local?
					# Create a new repo on the same local machine. Just use existing pull code in reverse.
					to.pull(self)
				else
					run "ssh #{to.hostname} 'mkdir -p #{to.path}'"
					run "scp -rpqB #{git_path} #{to.hostname}:#{to.path}"
				end
			end
		end

		def local?
			return true if hostname == Socket.gethostname
			return false if url =~ /:/
			true
		end

		def hostname
			url =~ /^([^:^\/]+):(.+)/ ? $1 : nil
		end

		def path
			url =~ /^([^:^\/]+):(.+)/ ? $2 : nil
		end
	end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
ohloh_scm-2.5.1 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.14 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.13 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.12 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.11 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.10 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.9 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.8 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.7 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.6 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.5 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.4 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.3 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.1 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.4.0 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.3.5 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.3.4 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.3.2 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.3.1 lib/ohloh_scm/adapters/git/push.rb
ohloh_scm-2.3.0 lib/ohloh_scm/adapters/git/push.rb