spiegel 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4f5a71c916bb50eece9d7324be9534463ba12ee3
4
+ data.tar.gz: afbd34bbfb2c35e1561c323e891a9878af8b546b
5
+ SHA512:
6
+ metadata.gz: 72f349f328331acf2f18de50deef9d8c283aac060bdb8fabbf679fbd248650687c8b38abc7515631dde499e84dc4a174a81b2ef7773e36207ceb722d3fb8b77f
7
+ data.tar.gz: 9360e888f0fdaf1c20cb25b887f43a1a28548dbc887a295540886af747f93ad51cd388cc44abe36bfe7b46e33df939d5f1e63cf234600b17b3cdc3249111a2f9
@@ -0,0 +1,11 @@
1
+ *~
2
+ *.log
3
+ *.pid
4
+ *.out
5
+ *.swp
6
+ *.gem
7
+ .DS_Store
8
+ .vagrant
9
+ .yarddoc
10
+ repos
11
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'thin'
6
+
7
+ group :development do
8
+ gem 'pry'
9
+ gem 'rake'
10
+ gem 'yard'
11
+ gem 'version'
12
+ gem 'rubygems-tasks'
13
+ end
14
+
15
+ group :test do
16
+ gem 'minitest'
17
+ end
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ spiegel (0.0.0)
5
+ sinatra (~> 1.4)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.1.0)
11
+ daemons (1.1.9)
12
+ eventmachine (1.0.3)
13
+ method_source (0.8.2)
14
+ minitest (5.5.0)
15
+ pry (0.10.1)
16
+ coderay (~> 1.1.0)
17
+ method_source (~> 0.8.1)
18
+ slop (~> 3.4)
19
+ rack (1.6.0)
20
+ rack-protection (1.5.3)
21
+ rack
22
+ rake (10.4.2)
23
+ rubygems-tasks (0.2.4)
24
+ sinatra (1.4.5)
25
+ rack (~> 1.4)
26
+ rack-protection (~> 1.4)
27
+ tilt (~> 1.3, >= 1.3.4)
28
+ slop (3.6.0)
29
+ thin (1.6.3)
30
+ daemons (~> 1.0, >= 1.0.9)
31
+ eventmachine (~> 1.0)
32
+ rack (~> 1.0)
33
+ tilt (1.4.1)
34
+ version (1.0.0)
35
+ yard (0.8.7.6)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ minitest
42
+ pry
43
+ rake
44
+ rubygems-tasks
45
+ spiegel!
46
+ thin
47
+ version
48
+ yard
@@ -0,0 +1,33 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'rake'
4
+
5
+
6
+ require 'rake/testtask'
7
+ Rake::TestTask.new(:test) do |test|
8
+ test.libs << 'lib' << 'test'
9
+ test.test_files = FileList['test/test*.rb']
10
+ test.verbose = true
11
+ end
12
+
13
+ task :default => :test
14
+
15
+
16
+ require 'yard'
17
+ YARD::Rake::YardocTask.new do |t|
18
+ t.files = %w[ --readme Readme.md lib/**/*.rb - VERSION ]
19
+ end
20
+
21
+
22
+ require 'rubygems/tasks'
23
+ Gem::Tasks.new({
24
+ push: true,
25
+ sign: {}
26
+ }) do |tasks|
27
+ tasks.console.command = 'pry'
28
+ end
29
+ Gem::Tasks::Sign::Checksum.new sha2: true
30
+
31
+
32
+ require 'rake/version_task'
33
+ Rake::VersionTask.new
@@ -0,0 +1,13 @@
1
+ ## Spiegel
2
+
3
+ Spiegel is a simple git mirroring service meant to be activated by GitLab Web Hooks. After installing Spiegel you can add a Web Hook for `http://your-spiegel-host:8888/` and your project will be automatically mirrored on any push. Projects are mirrored to `/var/data/spiegel/PROJECT_NAME.git`, and logs are kept at `/var/log/spiegel`, while Spiegel itself lives at `/opt/spiegel`. You can use the "spiegel" service to manage the application.
4
+
5
+ To install:
6
+
7
+ $ gem install unicorn sinatra # You might need sudo...
8
+ $ git clone --depth=1 http://git.bluejeansnet.com/inf/spiegel.git # Or some mirror
9
+ $ spiegel/install-or-upgrade.sh # You might read it first
10
+ $ rm -r spiegel # Lives in /opt/spiegel
11
+
12
+ To upgrade, just repeat the install procedure.
13
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/art.txt ADDED
@@ -0,0 +1,39 @@
1
+
2
+ ___ ___ ___ ___ ___ ___
3
+ /\ \ /\ \ ___ /\ \ /\ \ /\ \ /\__\
4
+ /::\ \ /::\ \ /\ \ /::\ \ /::\ \ /::\ \ /:/ /
5
+ /:/\ \ \ /:/\:\ \ \:\ \ /:/\:\ \ /:/\:\ \ /:/\:\ \ /:/ /
6
+ _\:\~\ \ \ /::\~\:\ \ /::\__\ /::\~\:\ \ /:/ \:\ \ /::\~\:\ \ /:/ /
7
+ /\ \:\ \ \__\ /:/\:\ \:\__\ __/:/\/__/ /:/\:\ \:\__\ /:/__/_\:\__\ /:/\:\ \:\__\ /:/__/
8
+ \:\ \:\ \/__/ \/__\:\/:/ / /\/:/ / \:\~\:\ \/__/ \:\ /\ \/__/ \:\~\:\ \/__/ \:\ \
9
+ \:\ \:\__\ \::/ / \::/__/ \:\ \:\__\ \:\ \:\__\ \:\ \:\__\ \:\ \
10
+ \:\/:/ / \/__/ \:\__\ \:\ \/__/ \:\/:/ / \:\ \/__/ \:\ \
11
+ \::/ / \/__/ \:\__\ \::/ / \:\__\ \:\__\
12
+ \/__/ \/__/ \/__/ \/__/ \/__/
13
+
14
+
15
+ v1.1.2
16
+
17
+ Sean Clemmer / Blue Jeans Network
18
+
19
+
20
+
21
+ Why, hello there.
22
+
23
+ You're looking at Spiegel, a barebones git mirror.
24
+
25
+
26
+ You can grab a copy of a repo like so:
27
+
28
+ git clone git://%{server_name}/some-repo.git
29
+
30
+ If you'd like your own Spiegel, clone and follow the README:
31
+
32
+ git clone git://%{server_name}/inf/spiegel.git
33
+
34
+
35
+ That's about it.
36
+
37
+
38
+
39
+
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env ruby
2
+ require 'json'
3
+ require 'logger'
4
+ require 'fileutils'
5
+
6
+ require 'sinatra/base'
7
+
8
+ require 'spiegel'
9
+
10
+ URL = 'http://git.bluejeansnet.com/'
11
+ ROOT = File.join File.dirname(File.expand_path(__FILE__)), '..'
12
+ REPO_DIR = '/var/data/spiegel'
13
+ ART = File.read File.join(ROOT, 'art.txt')
14
+ INTERVAL = 60 # Seconds
15
+
16
+ logger = Logger.new STDOUT
17
+
18
+ def bare_repos
19
+ bare_repos = Dir["#{REPO_DIR}/*.git"]
20
+ bare_repos += Dir["#{REPO_DIR}/*/*.git"]
21
+ bare_repos.sort.uniq
22
+ end
23
+
24
+
25
+ # Update repos in background
26
+ fork do
27
+ loop do
28
+ repos = Hash.new
29
+ bare_repos.each do |repo|
30
+ name = repo.sub "#{REPO_DIR}/", ''
31
+ name = name.sub '.git', ''
32
+ repos[name] = repo
33
+ end
34
+
35
+ repos.each do |name, repo|
36
+ begin
37
+ Dir.chdir repo
38
+ system 'git remote update >/dev/null 2>&1'
39
+ rescue
40
+ end
41
+ logger.info "Updated #{name}"
42
+ sleep 1
43
+ end
44
+
45
+ sleep INTERVAL
46
+ end
47
+ end
48
+
49
+
50
+
51
+ # Accept new repos via WebHook POSTs
52
+ class Spiegel::App < Sinatra::Application
53
+ get '/' do
54
+ content_type :txt
55
+ repos = []
56
+ bare_repos.each do |repo|
57
+ Dir.chdir(repo) do
58
+ name = repo.sub "#{REPO_DIR}/", ''
59
+ name = name.sub '.git', ''
60
+ git_info = `git log -1 --relative-date --pretty="[%ar] (%h) %s"`
61
+ git_info = "[syncing...]\n" if git_info.empty?
62
+ end
63
+ repos << [name, git_info]
64
+ end
65
+ repos = repos.sort_by { |r| r[0] }
66
+ repos = repos.map { |r| r[0] + ' ' + r[1] }
67
+ art = ART % {
68
+ server_name: request.env['SERVER_NAME'],
69
+ server_port: request.env['SERVER_NAME']
70
+ }
71
+ return art + repos * "\n" + "\n"
72
+ end
73
+
74
+ post '/' do
75
+ data = JSON::parse request.body.read
76
+ url = data['repository']['url']
77
+ url.gsub! 'git://git/', URL
78
+ url.gsub! 'git://git.bluejeansnet.com/', URL
79
+ url.gsub! 'git@git:', URL
80
+ url.gsub! 'git@git.bluejeansnet.com:', URL
81
+ name = url.split('.com/', 2)[1]
82
+ repo = File::join(REPO_DIR, name)
83
+ unless File::exist? repo
84
+ FileUtils.mkdir_p File::dirname(repo)
85
+ clone = 'git clone --mirror %s %s.tmp' % [ url, repo ]
86
+ move = 'mv %s.tmp %s' % [ repo, repo ]
87
+ system '%s >/dev/null && %s' % [ clone, move ]
88
+ logger.info "Cloned #{name.sub '.git', ''}"
89
+ end
90
+ return true
91
+ end
92
+ end
93
+
94
+ Spiegel::App.run!
@@ -0,0 +1 @@
1
+ require_relative 'spiegel/metadata'
@@ -0,0 +1,29 @@
1
+ module Spiegel
2
+
3
+ # We use a VERSION file to tie into our build pipeline
4
+ VERSION = File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).strip
5
+
6
+ # We don't really do all that much, be humble
7
+ SUMMARY = 'Spiegel is a simple git mirroring service meant to be activated by GitLab Web Hooks.'
8
+
9
+ # Your benevolent dictator for life
10
+ AUTHOR = 'Sean Clemmer'
11
+
12
+ # Turn here to strangle your dictator
13
+ EMAIL = 'sclemmer@bluejeans.com'
14
+
15
+ # Every project deserves its own ASCII art
16
+ ART = <<-'EOART' % VERSION
17
+ ___ ___ ___ ___ ___ ___
18
+ /\ \ /\ \ ___ /\ \ /\ \ /\ \ /\__\
19
+ /::\ \ /::\ \ /\ \ /::\ \ /::\ \ /::\ \ /:/ /
20
+ /:/\ \ \ /:/\:\ \ \:\ \ /:/\:\ \ /:/\:\ \ /:/\:\ \ /:/ /
21
+ _\:\~\ \ \ /::\~\:\ \ /::\__\ /::\~\:\ \ /:/ \:\ \ /::\~\:\ \ /:/ /
22
+ /\ \:\ \ \__\ /:/\:\ \:\__\ __/:/\/__/ /:/\:\ \:\__\ /:/__/_\:\__\ /:/\:\ \:\__\ /:/__/
23
+ \:\ \:\ \/__/ \/__\:\/:/ / /\/:/ / \:\~\:\ \/__/ \:\ /\ \/__/ \:\~\:\ \/__/ \:\ \
24
+ \:\ \:\__\ \::/ / \::/__/ \:\ \:\__\ \:\ \:\__\ \:\ \:\__\ \:\ \
25
+ \:\/:/ / \/__/ \:\__\ \:\ \/__/ \:\/:/ / \:\ \/__/ \:\ \
26
+ \::/ / \/__/ \:\__\ \::/ / \:\__\ \:\__\
27
+ \/__/ \/__/ \/__/ \/__/ \/__/
28
+ EOART
29
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path(File.join('..', 'lib'), __FILE__)
3
+ require 'spiegel'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'spiegel'
7
+ s.version = Spiegel::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.author = Spiegel::AUTHOR
10
+ s.email = Spiegel::EMAIL
11
+ s.summary = Spiegel::SUMMARY
12
+ s.description = Spiegel::SUMMARY + '.'
13
+
14
+ s.add_runtime_dependency 'sinatra', '~> 1.4'
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- test/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File::basename(f) }
19
+ s.require_paths = %w[ lib ]
20
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spiegel
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sean Clemmer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ description: Spiegel is a simple git mirroring service meant to be activated by GitLab
28
+ Web Hooks..
29
+ email: sclemmer@bluejeans.com
30
+ executables:
31
+ - spiegel
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - Rakefile
39
+ - Readme.md
40
+ - VERSION
41
+ - art.txt
42
+ - bin/spiegel
43
+ - lib/spiegel.rb
44
+ - lib/spiegel/metadata.rb
45
+ - spiegel.gemspec
46
+ homepage:
47
+ licenses: []
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.2.2
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Spiegel is a simple git mirroring service meant to be activated by GitLab
69
+ Web Hooks.
70
+ test_files: []