mortar 0.13.4 → 0.13.5

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.
@@ -169,13 +169,17 @@ class Mortar::Command::Base
169
169
  end
170
170
  end
171
171
 
172
- def register_api_call(name, is_public)
173
- project_id = nil
172
+ def ask_public(is_public)
174
173
  if is_public
175
174
  unless confirm("Public projects allow anyone to view and fork the code in this project\'s repository. Are you sure? (y/n)")
176
175
  error("Mortar project was not registered")
177
- end
176
+ end
178
177
  end
178
+ end
179
+
180
+ def register_api_call(name, is_public)
181
+ project_id = nil
182
+
179
183
  is_private = !is_public # is private required by restful api
180
184
  validate_project_name(name)
181
185
  'registering project....\n'
@@ -92,6 +92,7 @@ class Mortar::Command::Projects < Mortar::Command::Base
92
92
  is_public = false
93
93
  if options[:public]
94
94
  is_public= true
95
+ ask_public(is_public)
95
96
  end
96
97
  validate_project_name(name)
97
98
  project_id = register_api_call(name,is_public)
@@ -124,7 +125,7 @@ class Mortar::Command::Projects < Mortar::Command::Base
124
125
  error("Usage: mortar projects:register PROJECT\nMust specify PROJECT.")
125
126
  end
126
127
  validate_arguments!
127
-
128
+ ask_public(options[:public])
128
129
  #nil is non existant project_id because it hasn't been posted yet
129
130
  register_do(name, options[:public], options[:embedded], nil)
130
131
 
@@ -227,7 +228,7 @@ class Mortar::Command::Projects < Mortar::Command::Base
227
228
  end
228
229
  end
229
230
  is_public = options[:public]
230
-
231
+ ask_public(is_public)
231
232
  git.clone(git_url, name, "base")
232
233
  Dir.chdir(name)
233
234
  # register a nil project id because it hasn't been created yet
@@ -236,7 +237,7 @@ class Mortar::Command::Projects < Mortar::Command::Base
236
237
  git.push_master
237
238
  # We want the default remote to be the Mortar managed repo.
238
239
  git.git("fetch --all")
239
- git.git("branch --set-upstream-to mortar/master")
240
+ git.set_upstream('mortar/master')
240
241
  display "Your project is ready for use. Type 'mortar help' to see the commands you can perform on the project.\n\n"
241
242
  end
242
243
  end
data/lib/mortar/git.rb CHANGED
@@ -29,16 +29,16 @@ module Mortar
29
29
  # core commands
30
30
  #
31
31
 
32
- def has_git?
32
+ def has_git?(major_version=1, minor_version=7, revision_version=7)
33
33
  # Needs to have git version 1.7.7 or greater. Earlier versions lack
34
34
  # the necessary untracked option for stash.
35
35
  git_version_output, has_git = run_cmd("git --version")
36
36
  if has_git
37
37
  git_version = git_version_output.split(" ")[2]
38
38
  versions = git_version.split(".")
39
- is_ok_version = versions[0].to_i >= 2 ||
40
- ( versions[0].to_i == 1 && versions[1].to_i >= 8 ) ||
41
- ( versions[0].to_i == 1 && versions[1].to_i == 7 && versions[2].to_i >= 7)
39
+ is_ok_version = versions[0].to_i >= major_version + 1 ||
40
+ ( versions[0].to_i == major_version && versions[1].to_i >= minor_version + 1 ) ||
41
+ ( versions[0].to_i == major_version && versions[1].to_i == minor_version && versions[2].to_i >= revision_version)
42
42
  end
43
43
  has_git && is_ok_version
44
44
  end
@@ -465,6 +465,14 @@ module Mortar
465
465
  git("remote add #{name} #{url}")
466
466
  end
467
467
 
468
+ def set_upstream(remote_branch_name)
469
+ if has_git?(major_version=1, minor_version=8, revision_version=0)
470
+ git("branch --set-upstream-to #{remote_branch_name}")
471
+ else
472
+ git("branch --set-upstream master #{remote_branch_name}")
473
+ end
474
+ end
475
+
468
476
  #
469
477
  # rev-parse
470
478
  #
@@ -16,5 +16,5 @@
16
16
 
17
17
  module Mortar
18
18
  # see http://semver.org/
19
- VERSION = "0.13.4"
19
+ VERSION = "0.13.5"
20
20
  end
@@ -265,7 +265,6 @@ STDERR
265
265
  it "Confirms if user wants to create a public project, exits when user says no" do
266
266
  project_name = "some_new_project"
267
267
  project_id = "1234"
268
- mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
269
268
  any_instance_of(Mortar::Command::Projects) do |base|
270
269
  mock(base).ask.with_any_args.times(1) { 'n' }
271
270
  end
@@ -523,7 +522,7 @@ STDERR
523
522
  mock(@git).remote_add("mortar", project_git_url)
524
523
  mock(@git).push_master
525
524
  mock(@git).git("fetch --all")
526
- mock(@git).git("branch --set-upstream-to mortar/master")
525
+ mock(@git).set_upstream("mortar/master")
527
526
  any_instance_of(Mortar::Command::Projects) do |base|
528
527
  mock(base).ask.with_any_args.times(1) { 'y' }
529
528
  end
@@ -51,6 +51,16 @@ module Mortar
51
51
  @git.has_git?.should be_true
52
52
  end
53
53
 
54
+ it "returns true with supported version with params" do
55
+ mock(@git).run_cmd("git --version").returns(["git version 1.8.0", 0])
56
+ @git.has_git?(major_version=1,minor_version=8,revision_version=0).should be_true
57
+ end
58
+
59
+ it "returns false with unsupported version with params" do
60
+ mock(@git).run_cmd("git --version").returns(["git version 1.7.12", 0])
61
+ @git.has_git?(major_version=1,minor_version=8,revision_version=0).should be_false
62
+ end
63
+
54
64
  end
55
65
 
56
66
  context "has_any_commits" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mortar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.4
4
+ version: 0.13.5
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: 2014-01-29 00:00:00.000000000 Z
12
+ date: 2014-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc