gitjour 5.0.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -1
- data/README.txt +8 -1
- data/bin/gitjour +4 -55
- data/lib/gitjour.rb +1 -5
- data/lib/gitjour/application.rb +95 -0
- data/lib/gitjour/version.rb +1 -1
- metadata +3 -3
- data/log/debug.log +0 -0
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
data/bin/gitjour
CHANGED
@@ -1,58 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
GitService = Struct.new(:name, :host, :description)
|
8
|
-
|
9
|
-
def service_list(looking_for = nil)
|
10
|
-
wait_seconds = 5
|
11
|
-
|
12
|
-
service_list = Set.new
|
13
|
-
waiting_thread = Thread.new { sleep wait_seconds }
|
14
|
-
|
15
|
-
service = DNSSD.browse "_git._tcp" do |reply|
|
16
|
-
DNSSD.resolve reply.name, reply.type, reply.domain do |resolve_reply|
|
17
|
-
service_list << GitService.new(reply.name, resolve_reply.target, resolve_reply.text_record['description'])
|
18
|
-
if looking_for && reply.name == looking_for
|
19
|
-
waiting_thread.kill
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
puts "Gathering for up to #{wait_seconds} seconds..."
|
24
|
-
waiting_thread.join
|
25
|
-
service.stop
|
26
|
-
service_list
|
3
|
+
require 'gitjour'
|
4
|
+
trap "INT" do
|
5
|
+
exit!
|
27
6
|
end
|
28
|
-
|
29
|
-
case ARGV.shift
|
30
|
-
when "list"
|
31
|
-
service_list.each do |service|
|
32
|
-
puts "#{service.name} on #{service.host}: gitjour clone #{service.name}"
|
33
|
-
puts " #{service.description}" if service.description && service.description != ''
|
34
|
-
end
|
35
|
-
when "clone"
|
36
|
-
name_of_share = ARGV.shift || fail("You have to pass in a name")
|
37
|
-
host = service_list(name_of_share).detect{|service| service.name == name_of_share}.host
|
38
|
-
system("git clone git://#{host}/ #{name_of_share}")
|
39
|
-
when "serve"
|
40
|
-
name = ARGV.shift || File.basename(Dir.pwd)
|
41
|
-
tr = DNSSD::TextRecord.new
|
42
|
-
tr['description'] = File.read(".git/description") rescue "a git project"
|
43
|
-
DNSSD.register(name, "_git._tcp", 'local', 9148, tr.encode) do |register_reply|
|
44
|
-
p register_reply
|
45
|
-
end
|
46
|
-
`git-daemon --verbose --export-all --base-path=#{Dir.pwd}`
|
47
|
-
else
|
48
|
-
puts "Serve up and use git repositories via Bonjour/DNSSD."
|
49
|
-
puts "Usage: gitjour <command> [name]"
|
50
|
-
puts
|
51
|
-
puts " list Lists available repositories."
|
52
|
-
puts " clone Clone a gitjour served repository."
|
53
|
-
puts " serve Serve up the current directory via gitjour."
|
54
|
-
puts " Optionally pass name to not use pwd."
|
55
|
-
puts
|
56
|
-
end
|
57
|
-
|
58
|
-
|
7
|
+
Gitjour::Application.run(*ARGV)
|
data/lib/gitjour.rb
CHANGED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'dnssd'
|
3
|
+
require 'set'
|
4
|
+
Thread.abort_on_exception = true
|
5
|
+
|
6
|
+
module Gitjour
|
7
|
+
GitService = Struct.new(:name, :host, :description)
|
8
|
+
class Application
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def run(operation = nil, argument = nil)
|
12
|
+
case operation
|
13
|
+
when "list"
|
14
|
+
service_list.each do |service|
|
15
|
+
puts "=== #{service.name} on #{service.host} ==="
|
16
|
+
puts " gitjour clone #{service.name}"
|
17
|
+
puts " #{service.description}" if service.description && service.description != '' && service.description !~ /^Unnamed repository/
|
18
|
+
puts
|
19
|
+
end
|
20
|
+
when "clone"
|
21
|
+
clone(repository_name)
|
22
|
+
when "serve"
|
23
|
+
serve(argument)
|
24
|
+
else
|
25
|
+
help
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def clone(repository_name)
|
31
|
+
name_of_share = repository_name || fail("You have to pass in a name")
|
32
|
+
host = service_list(name_of_share).detect{|service| service.name == name_of_share}.host rescue exit_with!("Couldn't find #{name_of_share}")
|
33
|
+
system("git clone git://#{host}/ #{name_of_share}/")
|
34
|
+
|
35
|
+
end
|
36
|
+
def serve(path)
|
37
|
+
path ||= Dir.pwd
|
38
|
+
path = File.expand_path(path)
|
39
|
+
File.exists?("#{path}/.git") ? announce_repo(path) : Dir["#{path}/*"].each{|dir| announce_repo(dir) if File.directory?(dir)}
|
40
|
+
`git-daemon --verbose --export-all --base-path=#{path} --base-path-relaxed`
|
41
|
+
end
|
42
|
+
|
43
|
+
def help
|
44
|
+
puts "Serve up and use git repositories via Bonjour/DNSSD."
|
45
|
+
puts "Usage: gitjour <command> [name]"
|
46
|
+
puts
|
47
|
+
puts " list Lists available repositories."
|
48
|
+
puts " clone Clone a gitjour served repository."
|
49
|
+
puts " serve Serve up the current directory via gitjour."
|
50
|
+
puts " Optionally pass name to not use pwd."
|
51
|
+
puts
|
52
|
+
end
|
53
|
+
|
54
|
+
def exit_with!(message)
|
55
|
+
STDERR.puts message
|
56
|
+
exit!
|
57
|
+
end
|
58
|
+
|
59
|
+
def service_list(looking_for = nil)
|
60
|
+
wait_seconds = 5
|
61
|
+
|
62
|
+
service_list = Set.new
|
63
|
+
waiting_thread = Thread.new { sleep wait_seconds }
|
64
|
+
|
65
|
+
service = DNSSD.browse "_git._tcp" do |reply|
|
66
|
+
DNSSD.resolve reply.name, reply.type, reply.domain do |resolve_reply|
|
67
|
+
service_list << GitService.new(reply.name, resolve_reply.target, resolve_reply.text_record['description'])
|
68
|
+
if looking_for && reply.name == looking_for
|
69
|
+
waiting_thread.kill
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
puts "Gathering for up to #{wait_seconds} seconds..."
|
74
|
+
waiting_thread.join
|
75
|
+
service.stop
|
76
|
+
service_list
|
77
|
+
end
|
78
|
+
|
79
|
+
def announce_repo(path)
|
80
|
+
return unless File.exists?("#{path}/.git")
|
81
|
+
name = "#{File.basename(path)}"
|
82
|
+
tr = DNSSD::TextRecord.new
|
83
|
+
tr['description'] = File.read(".git/description") rescue "a git project"
|
84
|
+
DNSSD.register(name, "_git._tcp", 'local', 9148, tr.encode) do |register_reply|
|
85
|
+
puts "Registered #{name}. Starting service."
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
|
data/lib/gitjour/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitjour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Fowler
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2008-05-
|
14
|
+
date: 2008-05-31 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -45,8 +45,8 @@ files:
|
|
45
45
|
- config/hoe.rb
|
46
46
|
- config/requirements.rb
|
47
47
|
- lib/gitjour.rb
|
48
|
+
- lib/gitjour/application.rb
|
48
49
|
- lib/gitjour/version.rb
|
49
|
-
- log/debug.log
|
50
50
|
- script/destroy
|
51
51
|
- script/generate
|
52
52
|
- script/txt2html
|
data/log/debug.log
DELETED
File without changes
|