gitstagram 0.0.1 → 0.0.2
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 +2 -0
- data/bin/gitstagram +1 -1
- data/gitstagram.gemspec +1 -1
- data/lib/gitstagram/git_dir.rb +18 -3
- data/lib/gitstagram/post-commit +2 -2
- data/lib/gitstagram/version.rb +1 -1
- data/spec/git_dir_spec.rb +4 -4
- metadata +2 -2
data/.gitignore
CHANGED
data/bin/gitstagram
CHANGED
data/gitstagram.gemspec
CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
|
|
5
5
|
gem.email = ["g.marcilhacy@gmail.com"]
|
6
6
|
gem.description = gem.summary = "Take a snapshot after each commit."
|
7
7
|
gem.homepage = "https://github.com/gregorym/gitstagram"
|
8
|
-
|
8
|
+
|
9
9
|
gem.executables = ['gitstagram']
|
10
10
|
gem.files = `git ls-files | grep -v myapp`.split("\n")
|
11
11
|
gem.test_files = `git ls-files -- spec/*`.split("\n")
|
data/lib/gitstagram/git_dir.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
module Gitstagram
|
2
2
|
class GitDir < Dir
|
3
3
|
|
4
|
+
def initialize(path)
|
5
|
+
@path = path
|
6
|
+
end
|
7
|
+
|
4
8
|
#
|
5
9
|
# Returns true if the current directory is a git directory.
|
6
10
|
## Check the presence of .git in the folder
|
7
11
|
#
|
8
12
|
def is_git_directory?
|
9
|
-
Dir.
|
13
|
+
Dir.entries('.').include? '.git'
|
10
14
|
end
|
11
15
|
alias_method :is_git_dir?, :is_git_directory?
|
12
16
|
|
@@ -15,14 +19,14 @@ module Gitstagram
|
|
15
19
|
# Returns true if the git directory already has a post-commit hook.
|
16
20
|
#
|
17
21
|
def has_post_commit_hook?
|
18
|
-
Dir.
|
22
|
+
Dir.entries('.git/hooks').include? 'post-commit'
|
19
23
|
end
|
20
24
|
|
21
25
|
#
|
22
26
|
# Remove post-commit file from .git/hooks
|
23
27
|
#
|
24
28
|
def delete_post_commit
|
25
|
-
file_path = path + '/.git/hooks/post-commit'
|
29
|
+
file_path = @path + '/.git/hooks/post-commit'
|
26
30
|
if File.exists? file_path
|
27
31
|
File.delete file_path
|
28
32
|
end
|
@@ -37,4 +41,15 @@ module Gitstagram
|
|
37
41
|
File.open('./.git/hooks/post-commit', 'w', 0755) {|f| f.write(file) }
|
38
42
|
end
|
39
43
|
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if RUBY_VERSION =~ /^1\.8/
|
47
|
+
class Dir
|
48
|
+
class << self
|
49
|
+
def exists? (path)
|
50
|
+
File.directory?(path)
|
51
|
+
end
|
52
|
+
alias_method :exist?, :exists?
|
53
|
+
end
|
54
|
+
end
|
40
55
|
end
|
data/lib/gitstagram/post-commit
CHANGED
@@ -4,12 +4,12 @@ require 'rubygems'
|
|
4
4
|
begin
|
5
5
|
require 'gitstagram'
|
6
6
|
rescue LoadError
|
7
|
-
STDERR.puts 'Gistagram is not install. Run: gem install
|
7
|
+
STDERR.puts 'Gistagram is not install. Run: gem install gitstagram'
|
8
8
|
end
|
9
9
|
|
10
10
|
begin
|
11
11
|
Gitstagram::Snapshot.smile
|
12
|
-
rescue e
|
12
|
+
rescue Exception => e
|
13
13
|
STDERR.puts e.message
|
14
14
|
STDERR.puts e.backtrace.join(', ')
|
15
15
|
end
|
data/lib/gitstagram/version.rb
CHANGED
data/spec/git_dir_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Gitstagram::GitDir do
|
|
8
8
|
describe "#is_git_directory?" do
|
9
9
|
context 'folder contains a .git directory' do
|
10
10
|
before do
|
11
|
-
stub(Dir).
|
11
|
+
stub(Dir).entries { ['.git'] }
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should return true' do
|
@@ -18,7 +18,7 @@ describe Gitstagram::GitDir do
|
|
18
18
|
|
19
19
|
context 'folder does not contain a .git directory' do
|
20
20
|
before do
|
21
|
-
stub(Dir).
|
21
|
+
stub(Dir).entries { ['hello', 'world'] }
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should return false' do
|
@@ -30,7 +30,7 @@ describe Gitstagram::GitDir do
|
|
30
30
|
describe "#has_post_commit_hook" do
|
31
31
|
context "hooks folder contains a post-commit file" do
|
32
32
|
before do
|
33
|
-
stub(Dir).
|
33
|
+
stub(Dir).entries { ['post-commit', 'pre-commit.sample'] }
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should return true" do
|
@@ -41,7 +41,7 @@ describe Gitstagram::GitDir do
|
|
41
41
|
|
42
42
|
context "hooks folder does not contain a post-commit file" do
|
43
43
|
before do
|
44
|
-
stub(Dir).
|
44
|
+
stub(Dir).entries { ['post-commit.sample', 'pre-commit.sample'] }
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should return true" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitstagram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- .gitignore
|
39
39
|
- Gemfile
|
40
40
|
- README.md
|
41
|
+
- bin/gitstagram
|
41
42
|
- gitstagram.gemspec
|
42
43
|
- lib/gitstagram.rb
|
43
44
|
- lib/gitstagram/cli.rb
|
@@ -56,7 +57,6 @@ files:
|
|
56
57
|
- tools/.DS_Store
|
57
58
|
- tools/imagesnap
|
58
59
|
- tools/tlassemble
|
59
|
-
- bin/gitstagram
|
60
60
|
homepage: https://github.com/gregorym/gitstagram
|
61
61
|
licenses: []
|
62
62
|
post_install_message:
|