not-quite-submodules 0.3.0 → 0.4.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -11,6 +11,7 @@ class NotQuiteSubmodules
11
11
  def initialize(repository, target_path, args = {})
12
12
  args[:target_path] = target_path
13
13
  @update_interval = args[:update_interval] || DEFAULT_UPDATE_INTERVAL
14
+ @force_update_to = args[:force_update_to]
14
15
 
15
16
  if args[:temp_path].nil?
16
17
  tmp_name = (Digest::SHA1.hexdigest repository)
@@ -24,29 +25,30 @@ class NotQuiteSubmodules
24
25
  end
25
26
 
26
27
  tags = get_repository_tags(args[:temp_path]).map { |x| Versionomy.parse(x) }.sort
27
- if configuration_needs_update?(args[:temp_path], tags)
28
+ if configuration_needs_update?(args[:target_path], tags)
28
29
  update_target_path(args[:temp_path], args[:target_path], tags)
29
30
  end
30
31
  end
31
32
 
32
33
  private
33
34
 
34
- def configuration_needs_update?(temp_path, tags)
35
- return true if !ENV["FORCE_UPDATE"].nil?
36
- current_tag = get_current_tag(temp_path)
35
+ def configuration_needs_update?(target_path, tags)
36
+ return true if !ENV["FORCE_UPDATE"].nil? || @force_update_to
37
+ current_tag = get_current_tag(target_path)
38
+ tell("Currently checked out tag is #{current_tag}, latest tag is #{tags.last}")
37
39
  return true if current_tag.nil?
38
40
  current_tag < tags.last
39
41
  end
40
42
 
41
43
  # Checks out the latest tag and copies all files to the target path.
42
44
  def update_target_path(temp_path, target_path, tags)
43
- update_to = tags.last
45
+ update_to = @force_update_to || tags.last
44
46
  tell("About to update target path to tag '#{update_to}'")
45
47
 
46
48
  in_dir_do(temp_path) do
47
- execute_command("git checkout #{update_to}")
49
+ execute_command("git reset --hard #{update_to}")
48
50
  end
49
- set_current_tag(temp_path, update_to)
51
+ set_current_tag(target_path, update_to) if !@force_update_to
50
52
  tell("Updated to '#{update_to}'")
51
53
 
52
54
  tell("Copying updated files to '#{target_path}'")
@@ -62,6 +64,7 @@ private
62
64
  tell("Updating #{target_path}/.gitignore")
63
65
  files = in_dir_do(temp_path) { Dir.glob("*") }
64
66
  files.push(".gitignore")
67
+ files.push(".CURRENT_TAG")
65
68
  in_dir_do(target_path) do
66
69
  File.open(".gitignore", 'w+') { |f| f.write(files.join("\n")) }
67
70
  end
@@ -69,20 +72,20 @@ private
69
72
 
70
73
  # The file that contains the currently checked out tag (that is, the last tag
71
74
  # whose contents where copied to the configuration directory)
72
- def tag_file(temp_path)
73
- "#{temp_path}/.CURRENT_TAG"
75
+ def tag_file(target_path)
76
+ "#{target_path}/.CURRENT_TAG"
74
77
  end
75
78
 
76
- def get_current_tag(temp_path)
77
- dir = tag_file(temp_path)
79
+ def get_current_tag(target_path)
80
+ dir = tag_file(target_path)
78
81
  return nil if !File.exists?(dir)
79
82
  lines = File.read(dir).split("\n")
80
83
  return nil if lines.length < 1
81
84
  Versionomy.parse(lines.first)
82
85
  end
83
86
 
84
- def set_current_tag(temp_path, tag)
85
- File.open(tag_file(temp_path), 'w+') { |f| f.write(tag) }
87
+ def set_current_tag(target_path, tag)
88
+ File.open(tag_file(target_path), 'w+') { |f| f.write(tag) }
86
89
  end
87
90
 
88
91
  # Returns an array of tags specified for the cloned configuration repository
@@ -115,7 +118,9 @@ private
115
118
  in_dir_do(temp_path) do
116
119
  tell "Updating local configuration repository at '#{temp_path}'"
117
120
  execute_command("git checkout master")
118
- execute_command("git pull origin master --tags")
121
+ execute_command("git fetch")
122
+ execute_command("git fetch --tags")
123
+ execute_command("git reset --hard origin/master")
119
124
 
120
125
  head = execute_command("git rev-parse HEAD")[0,8]
121
126
  tell("Updated local configuration repository to #{head}")
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "not-quite-submodules"
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Lucas Jenss"]
12
- s.date = "2013-04-05"
12
+ s.date = "2013-04-18"
13
13
  s.description = "This gem can be used to automatically clone an update a git repository, relying on tags to see if a newer version of the repository is available."
14
14
  s.email = "lucas@x3ro.de"
15
15
  s.extra_rdoc_files = [
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
30
30
  s.homepage = "http://github.com/x3ro/not-quite-submodules"
31
31
  s.licenses = ["MIT"]
32
32
  s.require_paths = ["lib"]
33
- s.rubygems_version = "1.8.24"
33
+ s.rubygems_version = "1.8.25"
34
34
  s.summary = "This gem can be used to automatically clone and update a git repository."
35
35
 
36
36
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: not-quite-submodules
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-05 00:00:00.000000000 Z
12
+ date: 2013-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: versionomy
@@ -172,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  segments:
174
174
  - 0
175
- hash: -2096812673318803401
175
+ hash: -4321208896240466877
176
176
  required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  none: false
178
178
  requirements:
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 1.8.24
184
+ rubygems_version: 1.8.25
185
185
  signing_key:
186
186
  specification_version: 3
187
187
  summary: This gem can be used to automatically clone and update a git repository.