repo_tools 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e23abc6d2d8b5552272a5404d1db3f48591b250a
4
- data.tar.gz: 06a524c12ebdf68f86b63d81e3e731bb22fc265b
3
+ metadata.gz: 926c107e9eb4b6a7208322ea7ca32dbf6ab31212
4
+ data.tar.gz: 31baca717a1ed231df15a940f66af2c3f8fff815
5
5
  SHA512:
6
- metadata.gz: 07313212fcb967b26342415eab3930c6f44ad78e8446dbad11cb32976dc4331e4c887b75afab6993f239d274530fd6c3342bd108982578b5a545fe61303b781d
7
- data.tar.gz: 97ac9cc1c1f32f964069e42ce91cdc0591aa4bfb87cae2ebfc7fd6b66a5a468a4bf72959d0cbd7e9892d2acaff5c6bee34ba6be6a9a220382069f9d781a2945d
6
+ metadata.gz: 15d5485262dbfef94959734756d5caa9e2c21fdab103fa1d96bb2bfb42ae0778c3df298161a6d5faf5011e271bf6bcb64b6a20382f24c11c949f84578ec16b67
7
+ data.tar.gz: d7c34a817258f3c0b70c3b721fa92974a7c3da7f562d3391b9f8c2be85611fb509c21093161aca6f136730b7e9a1c87210f5833a56a1910828ddef7bb32f4ecd
@@ -0,0 +1,28 @@
1
+ module RepoTools; class GitStatusChecker
2
+
3
+ attr_reader :git_dirname
4
+
5
+ def initialize(git_dirname)
6
+ @git_dirname = git_dirname
7
+ end
8
+
9
+ def up_to_date?
10
+ return false unless git_initialized?
11
+ local_sha == remote_sha
12
+ end
13
+
14
+ def git_initialized?
15
+ return false unless File.directory?(git_dirname)
16
+ Dir.foreach(git_dirname).any? {|f| f == ".git"}
17
+ end
18
+
19
+ def local_sha
20
+ `git --git-dir #{git_dirname}/.git rev-parse master`
21
+ end
22
+
23
+ def remote_sha
24
+ `git --git-dir #{git_dirname}/.git rev-parse origin/master`
25
+ end
26
+
27
+ end; end
28
+
@@ -9,11 +9,16 @@ module RepoTools; class Puller
9
9
  end
10
10
 
11
11
  def clean_and_clone
12
+ return if git_status_checker.up_to_date?
12
13
  FileUtils.rm_rf destination_dirname
13
14
  clone
14
15
  log_clone
15
16
  end
16
17
 
18
+ def git_status_checker
19
+ GitStatusChecker.new(destination_dirname)
20
+ end
21
+
17
22
  def clone
18
23
  `git clone #{ssh_clone_url} #{destination_dirname}`
19
24
  end
@@ -1,3 +1,3 @@
1
1
  module RepoTools
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/repo_tools.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "repo_tools/version"
2
2
  require_relative "./repo_tools/puller.rb"
3
+ require_relative "./repo_tools/git_status_checker.rb"
3
4
 
4
5
  module RepoTools
5
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repo_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MrPowers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-24 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,6 +70,7 @@ files:
70
70
  - bin/console
71
71
  - bin/setup
72
72
  - lib/repo_tools.rb
73
+ - lib/repo_tools/git_status_checker.rb
73
74
  - lib/repo_tools/puller.rb
74
75
  - lib/repo_tools/version.rb
75
76
  - repo_tools.gemspec