Legit-the-Git 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.txt +1 -1
- data/legit-the-git.gemspec +2 -2
- data/lib/accuhook/command_line.rb +17 -6
- data/lib/accuhook/commit.rb +21 -19
- data/lib/accuhook/hooks/post-commit +3 -9
- data/lib/accuhook/hooks/post-receive +20 -0
- metadata +5 -5
- data/lib/accuhook/hooks/pre-commit +0 -10
data/LICENSE.txt
CHANGED
data/legit-the-git.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "Legit-the-Git"
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.3"
|
7
7
|
|
8
8
|
s.summary = "Git accurev bridge"
|
9
9
|
s.description = "Git hooks to help keep accurev and git in sync"
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
"lib/accuhook/command_line.rb",
|
23
23
|
"lib/accuhook/commit.rb",
|
24
24
|
"lib/accuhook/hooks/post-commit",
|
25
|
-
"lib/accuhook/hooks/
|
25
|
+
"lib/accuhook/hooks/post-receive"
|
26
26
|
]
|
27
27
|
s.add_runtime_dependency("grit", ["~> 2.3.0"])
|
28
28
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# Copyright (c) 2011 Grayson Manley
|
2
2
|
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license
|
3
3
|
|
4
|
+
require 'rubygems'
|
5
|
+
require 'accuhook'
|
4
6
|
require 'optparse'
|
5
7
|
require 'ostruct'
|
6
8
|
require 'fileutils'
|
@@ -16,7 +18,7 @@ module AccuHook
|
|
16
18
|
ret_val = AccuHook::Installation.new(options.path)
|
17
19
|
exit 0
|
18
20
|
when :version
|
19
|
-
puts 'Version 0.0.
|
21
|
+
puts 'Version 0.0.3'
|
20
22
|
exit 0
|
21
23
|
end
|
22
24
|
end
|
@@ -46,12 +48,21 @@ module AccuHook
|
|
46
48
|
install(repo)
|
47
49
|
end
|
48
50
|
|
49
|
-
def install(
|
50
|
-
|
51
|
-
FileUtils.mkdir repo_hooks_dir unless File.exist? repo_hooks_dir
|
51
|
+
def install(repo_path)
|
52
|
+
repository = Grit::Repo.new(repo_path)
|
52
53
|
|
53
|
-
|
54
|
-
|
54
|
+
repo_hooks = File.join(repo_path, '.git', 'hooks')
|
55
|
+
accurev_repo = File.join(repo_path, '.git', 'accurev.git')
|
56
|
+
accurev_hooks = File.join(repo_path, '.git', 'accurev.git', 'hooks')
|
57
|
+
|
58
|
+
repository.fork_bare(accurev_repo, :shared => false, :mirror => true)
|
59
|
+
repository.remote_add("accurev", accurev_repo)
|
60
|
+
|
61
|
+
FileUtils.mkdir accurev_hooks unless File.exist? accurev_hooks
|
62
|
+
FileUtils.mkdir repo_hooks unless File.exist? repo_hooks
|
63
|
+
|
64
|
+
FileUtils.install(File.join(File.dirname(__FILE__), "hooks", "post-commit"), repo_hooks, :mode => 0755)
|
65
|
+
FileUtils.install(File.join(File.dirname(__FILE__), "hooks", "post-receive"), accurev_hooks, :mode => 0755)
|
55
66
|
end
|
56
67
|
end
|
57
68
|
end
|
data/lib/accuhook/commit.rb
CHANGED
@@ -6,28 +6,30 @@ module AccuHook
|
|
6
6
|
class Commit
|
7
7
|
require File.dirname(__FILE__) + "/command"
|
8
8
|
|
9
|
-
def initialize(repository)
|
9
|
+
def initialize(repository, commit_object)
|
10
10
|
@command = AccuHook::Accurev::Command.new
|
11
|
-
|
12
|
-
commit(
|
11
|
+
puts commit_object.inspect
|
12
|
+
commit!(commit_object, repository)
|
13
13
|
end
|
14
14
|
|
15
|
-
def commit(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
15
|
+
def commit!(commit_object, repository)
|
16
|
+
commit_object.each do |commit|
|
17
|
+
commit.show.each do |diff|
|
18
|
+
case
|
19
|
+
when diff.new_file # Accurev add, then keep
|
20
|
+
@command.add("#{repository.working_dir}/#{diff.a_path}")
|
21
|
+
@command.keep("#{repository.working_dir}/#{diff.a_path}", commit.message)
|
22
|
+
when diff.deleted_file # accurev defunct
|
23
|
+
@command.defunct("#{repository.working_dir}/#{diff.a_path}", commit.message)
|
24
|
+
when diff.renamed_file # accurev defunct a_path, then add b_path (then keep)
|
25
|
+
puts "Renamed file detected"
|
26
|
+
@command.defunct("#{repository.working_dir}/#{diff.a_path}", commit.message)
|
27
|
+
@command.add("#{repository.working_dir}/#{diff.b_path}")
|
28
|
+
@command.keep("#{repository.working_dir}/#{diff.b_path}", commit.message)
|
29
|
+
else # Accurev regular keep
|
30
|
+
puts "Modified file detected"
|
31
|
+
@command.keep("#{repository.working_dir}/#{diff.a_path}", commit.message)
|
32
|
+
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -3,14 +3,8 @@
|
|
3
3
|
# Copyright (c) 2011 Grayson Manley
|
4
4
|
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
begin
|
9
|
-
require 'rubygems'
|
10
|
-
require 'accuhook'
|
11
|
-
rescue LoadError => e
|
12
|
-
require File.join(DEVELOPMENT_DIR, "lib", "accuhook")
|
6
|
+
def logged_in?
|
7
|
+
system("accurev secinfo > /dev/null 2>&1")
|
13
8
|
end
|
14
9
|
|
15
|
-
|
16
|
-
AccuHook::Accurev::Commit.new(repository)
|
10
|
+
puts "Remember to login before you push to accurev! (`accurev login`)" unless logged_in?
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright (c) 2011 Grayson Manley
|
4
|
+
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license
|
5
|
+
input = $stdin.gets
|
6
|
+
args = input.split(" ")
|
7
|
+
old_head_ref = args[0]
|
8
|
+
new_head_ref = args[1]
|
9
|
+
|
10
|
+
require 'rubygems'
|
11
|
+
require 'accuhook'
|
12
|
+
|
13
|
+
repository = Grit::Repo.new(File.join(File.dirname(__FILE__), "..", "..", ".."))
|
14
|
+
|
15
|
+
@commits = []
|
16
|
+
repository.commit_deltas_from(repository, old_head_ref, new_head_ref).each do |commit|
|
17
|
+
@commits << commit
|
18
|
+
end
|
19
|
+
|
20
|
+
AccuHook::Accurev::Commit.new(repository, @commits.reverse)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Legit-the-Git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Grayson Manley
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-12 00:00:00 -06:00
|
19
19
|
default_executable: accuhook
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -51,7 +51,7 @@ files:
|
|
51
51
|
- lib/accuhook/command_line.rb
|
52
52
|
- lib/accuhook/commit.rb
|
53
53
|
- lib/accuhook/hooks/post-commit
|
54
|
-
- lib/accuhook/hooks/
|
54
|
+
- lib/accuhook/hooks/post-receive
|
55
55
|
has_rdoc: true
|
56
56
|
homepage: http://github.com/gmanley/Legit-the-Git
|
57
57
|
licenses:
|
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright (c) 2011 Grayson Manley
|
4
|
-
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license
|
5
|
-
|
6
|
-
def logged_in?
|
7
|
-
system("accurev secinfo > /dev/null 2>&1")
|
8
|
-
end
|
9
|
-
|
10
|
-
raise "Please Login! (`accurev login`)" unless logged_in?
|