legit-the-git 0.0.5 → 0.0.6
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/.gitignore +3 -0
- data/README.txt +17 -0
- data/Rakefile +7 -0
- data/bin/legit-the-git +3 -3
- data/legit-the-git.gemspec +12 -17
- data/lib/legit-the-git/accurev.rb +30 -0
- data/lib/legit-the-git/command_line.rb +5 -8
- data/lib/legit-the-git/commit.rb +28 -30
- data/lib/legit-the-git/hooks/post-commit +0 -3
- data/lib/legit-the-git/hooks/pre-receive +2 -4
- data/lib/legit-the-git/version.rb +3 -0
- data/lib/legit-the-git.rb +1 -7
- metadata +13 -8
- data/lib/legit-the-git/command.rb +0 -34
data/.gitignore
ADDED
data/README.txt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
`gem install legit-the-git`
|
2
|
+
|
3
|
+
Usage legit-the-git [--version] [--help] <command>
|
4
|
+
|
5
|
+
Commands:
|
6
|
+
install Install the Accurev Git hook into the current directory
|
7
|
+
uninstall Remove legit-the-git from the current repo
|
8
|
+
|
9
|
+
Workflow:
|
10
|
+
Once installed commit your changes like usual. When you would like to push
|
11
|
+
those changes to accurev, just run `git push accurev`. This will sync new
|
12
|
+
commits from the current branch to the accurev server. Just make sure you
|
13
|
+
are logged into accurev!
|
14
|
+
|
15
|
+
Released under the MIT License (See LICENSE.txt file).
|
16
|
+
|
17
|
+
Copyright (c) 2011 Grayson Manley
|
data/Rakefile
ADDED
data/bin/legit-the-git
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
4
|
+
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
5
5
|
|
6
|
-
require 'rubygems'
|
7
6
|
require 'legit-the-git'
|
7
|
+
require 'legit-the-git/command_line'
|
8
8
|
|
9
9
|
LegitGit::CommandLine.execute(ARGV[0])
|
data/legit-the-git.gemspec
CHANGED
@@ -1,28 +1,23 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/legit-the-git/version", __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "legit-the-git"
|
6
|
-
s.version =
|
6
|
+
s.version = LegitGit::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
7
8
|
|
9
|
+
s.authors = ["Grayson Manley"]
|
10
|
+
s.email = ["gray.manley@gmail.com"]
|
11
|
+
|
12
|
+
s.homepage = "http://github.com/gmanley/legit-the-git"
|
8
13
|
s.summary = "Git accurev bridge"
|
9
14
|
s.description = "Git hooks to help keep accurev and git in sync"
|
10
|
-
s.homepage = "http://github.com/gmanley/legit-the-git"
|
11
15
|
s.license = "MIT"
|
12
|
-
|
13
|
-
s.
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
14
18
|
s.default_executable = "legit-the-git"
|
15
19
|
s.executables = ["legit-the-git"]
|
16
|
-
s.
|
17
|
-
|
18
|
-
"legit-the-git.gemspec",
|
19
|
-
"bin/legit-the-git",
|
20
|
-
"lib/legit-the-git.rb",
|
21
|
-
"lib/legit-the-git/command.rb",
|
22
|
-
"lib/legit-the-git/command_line.rb",
|
23
|
-
"lib/legit-the-git/commit.rb",
|
24
|
-
"lib/legit-the-git/hooks/post-commit",
|
25
|
-
"lib/legit-the-git/hooks/pre-receive"
|
26
|
-
]
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
27
22
|
s.add_runtime_dependency("grit", ["~> 2.3.0"])
|
28
23
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "shellwords"
|
2
|
+
|
3
|
+
module LegitGit
|
4
|
+
class Accurev
|
5
|
+
|
6
|
+
def add(file_path)
|
7
|
+
if File.directory?(file_path) # Recursively add directory (`accurev add -x -R {Dir}`)
|
8
|
+
execute("add -x -R \"#{file_path}\"")
|
9
|
+
else # Add single file (`accurev add {File}`)
|
10
|
+
execute("add \"#{file_path}\"")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def keep(file_path, message)
|
15
|
+
execute("keep -c \"#{message}\" \"#{file_path}\"")
|
16
|
+
end
|
17
|
+
|
18
|
+
def defunct(file_path, message)
|
19
|
+
execute("defunct -c \"#{message}\" \"#{file_path}\"")
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def execute(command)
|
24
|
+
args = Shellwords.split(command)
|
25
|
+
escaped_args = args.map {|arg| Shellwords.escape(arg)}
|
26
|
+
sub_command = Shellwords.join(escaped_args)
|
27
|
+
system("accurev #{sub_command}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,9 +1,6 @@
|
|
1
|
-
# Copyright (c) 2011 Grayson Manley
|
2
|
-
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require 'legit-the-git'
|
6
1
|
require 'fileutils'
|
2
|
+
require 'grit'
|
3
|
+
require 'legit-the-git/version'
|
7
4
|
|
8
5
|
module LegitGit
|
9
6
|
class CommandLine
|
@@ -28,18 +25,18 @@ EOS
|
|
28
25
|
|
29
26
|
case args
|
30
27
|
when "install"
|
31
|
-
installation =
|
28
|
+
installation = Installation.new(Dir.pwd)
|
32
29
|
installation.install
|
33
30
|
puts 'Successfully installed!'
|
34
31
|
puts "Run #{File.basename $0} --help for usage."
|
35
32
|
exit 0
|
36
33
|
when "uninstall"
|
37
|
-
installation =
|
34
|
+
installation = Installation.new(Dir.pwd)
|
38
35
|
installation.uninstall
|
39
36
|
puts 'Successfully uninstalled!'
|
40
37
|
exit 0
|
41
38
|
when "--version"
|
42
|
-
puts
|
39
|
+
puts LegitGit::VERSION
|
43
40
|
exit 0
|
44
41
|
else
|
45
42
|
puts help
|
data/lib/legit-the-git/commit.rb
CHANGED
@@ -1,37 +1,35 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'grit'
|
2
|
+
require 'legit-the-git/accurev'
|
3
3
|
|
4
4
|
module LegitGit
|
5
|
-
|
6
|
-
class Commit
|
7
|
-
require File.dirname(__FILE__) + "/command"
|
5
|
+
class Commit
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
def initialize(repository, commit_object)
|
8
|
+
@command = Accurev.new
|
9
|
+
commit!(commit_object, repository)
|
10
|
+
end
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
12
|
+
private
|
13
|
+
def commit!(commit_object, repository)
|
14
|
+
commit_object.each do |commit|
|
15
|
+
$stdout.puts "\e[\033[0;36mSyncing Commit \e[\033[0;32m#{commit.id_abbrev}\e[0m\n\e[\033[0;33m#{commit.message}\e[0m"
|
16
|
+
commit.show.each do |diff|
|
17
|
+
case
|
18
|
+
when diff.new_file # Accurev add, then keep
|
19
|
+
puts "New file detected"
|
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
|
+
puts "Deleted file detected"
|
24
|
+
@command.defunct("#{repository.working_dir}/#{diff.a_path}", commit.message)
|
25
|
+
when diff.renamed_file # accurev defunct a_path, then add b_path (then keep)
|
26
|
+
puts "Renamed file detected"
|
27
|
+
@command.defunct("#{repository.working_dir}/#{diff.a_path}", commit.message)
|
28
|
+
@command.add("#{repository.working_dir}/#{diff.b_path}")
|
29
|
+
@command.keep("#{repository.working_dir}/#{diff.b_path}", commit.message)
|
30
|
+
else # Accurev regular keep
|
31
|
+
puts "Modified file detected"
|
32
|
+
@command.keep("#{repository.working_dir}/#{diff.a_path}", commit.message)
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# Copyright (c) 2011 Grayson Manley
|
4
|
-
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license
|
5
3
|
input = $stdin.gets
|
6
4
|
args = input.split(" ")
|
7
5
|
old_head_ref = args[0]
|
8
6
|
new_head_ref = args[1]
|
9
7
|
|
10
|
-
require 'rubygems'
|
8
|
+
begin; require 'rubygems'; rescue LoadError; end # Needed? Since git will be calling this file I dunno what the ENV is like.
|
11
9
|
require 'legit-the-git'
|
12
10
|
|
13
11
|
repository = Grit::Repo.new(File.join(File.dirname(__FILE__), "..", "..", ".."))
|
@@ -17,4 +15,4 @@ repository.commit_deltas_from(repository, old_head_ref, new_head_ref).each do |c
|
|
17
15
|
@commits << commit
|
18
16
|
end
|
19
17
|
|
20
|
-
LegitGit::
|
18
|
+
LegitGit::Commit.new(repository, @commits.reverse)
|
data/lib/legit-the-git.rb
CHANGED
@@ -1,7 +1 @@
|
|
1
|
-
|
2
|
-
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require 'grit'
|
6
|
-
require File.dirname(__FILE__) + '/legit-the-git/command_line'
|
7
|
-
require File.dirname(__FILE__) + '/legit-the-git/commit'
|
1
|
+
require 'legit-the-git/commit'
|
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: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
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-
|
18
|
+
date: 2011-03-31 00:00:00 -05:00
|
19
19
|
default_executable: legit-the-git
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -35,7 +35,8 @@ dependencies:
|
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
description: Git hooks to help keep accurev and git in sync
|
38
|
-
email:
|
38
|
+
email:
|
39
|
+
- gray.manley@gmail.com
|
39
40
|
executables:
|
40
41
|
- legit-the-git
|
41
42
|
extensions: []
|
@@ -43,15 +44,19 @@ extensions: []
|
|
43
44
|
extra_rdoc_files: []
|
44
45
|
|
45
46
|
files:
|
47
|
+
- .gitignore
|
46
48
|
- LICENSE.txt
|
47
|
-
-
|
49
|
+
- README.txt
|
50
|
+
- Rakefile
|
48
51
|
- bin/legit-the-git
|
52
|
+
- legit-the-git.gemspec
|
49
53
|
- lib/legit-the-git.rb
|
50
|
-
- lib/legit-the-git/
|
54
|
+
- lib/legit-the-git/accurev.rb
|
51
55
|
- lib/legit-the-git/command_line.rb
|
52
56
|
- lib/legit-the-git/commit.rb
|
53
57
|
- lib/legit-the-git/hooks/post-commit
|
54
58
|
- lib/legit-the-git/hooks/pre-receive
|
59
|
+
- lib/legit-the-git/version.rb
|
55
60
|
has_rdoc: true
|
56
61
|
homepage: http://github.com/gmanley/legit-the-git
|
57
62
|
licenses:
|
@@ -82,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
87
|
requirements: []
|
83
88
|
|
84
89
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.
|
90
|
+
rubygems_version: 1.6.2
|
86
91
|
signing_key:
|
87
92
|
specification_version: 3
|
88
93
|
summary: Git accurev bridge
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011 Grayson Manley
|
2
|
-
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license
|
3
|
-
|
4
|
-
module LegitGit
|
5
|
-
module Accurev
|
6
|
-
class Command
|
7
|
-
require "shellwords"
|
8
|
-
|
9
|
-
def add(file_path)
|
10
|
-
if File.directory?(file_path) # Recursively add directory (`accurev add -x -R {Dir}`)
|
11
|
-
execute("add -x -R \"#{file_path}\"")
|
12
|
-
else # Add single file (`accurev add {File}`)
|
13
|
-
execute("add \"#{file_path}\"")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def keep(file_path, message)
|
18
|
-
execute("keep -c \"#{message}\" \"#{file_path}\"")
|
19
|
-
end
|
20
|
-
|
21
|
-
def defunct(file_path, message)
|
22
|
-
execute("defunct -c \"#{message}\" \"#{file_path}\"")
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
def execute(command)
|
27
|
-
args = Shellwords.split(command)
|
28
|
-
escaped_args = args.map {|arg| Shellwords.escape(arg)}
|
29
|
-
sub_command = Shellwords.join(escaped_args)
|
30
|
-
system("accurev #{sub_command}")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|