ebm 0.0.14 → 0.0.15

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
- SHA1:
3
- metadata.gz: 6ed5b9bfdba6c7db8b4b75cee27af82e801591a2
4
- data.tar.gz: 39ef0f6362ad6d0cb15394ac6e2bde14bdc2b65f
5
2
  SHA512:
6
- metadata.gz: 13933f2f82ea3277ccce683366f838f84f6c1d5b4d16b429c308a956b6024eda9e42cd726adac06f122648c17102246fc642f700b3f2236851be2f51ee1a6761
7
- data.tar.gz: b8a2f41f613527ed54f8f77d9c51be69cebe44e86c3749d6537e70e04dd9dcda332486f6a57a15c69818505d8f6c23884cbf54d033f7662abab5e9cec2160649
3
+ metadata.gz: f7b603272b2c9fc59edce589b9c11b4e5782d1edcf898b396e15f3fef9fb7dbbbd0fea03e9d0483bef301e96e8fc4dac1a03d530c99a37bb518946b850ae73d9
4
+ data.tar.gz: 00de09579c0f9729536c6c63e613b3ec6014e07421ec518610379cc9e8165c4a3a0168356c681e4f0e436ec4eb2460676e3309321e8d32cb01128b1266dcf5a4
5
+ SHA1:
6
+ metadata.gz: c749515fc92f8758856798292830057d2299b95c
7
+ data.tar.gz: 51601bc0d48c15c7b2b29e57e165a09f8c619f29
data/lib/commands/pull.rb CHANGED
@@ -29,6 +29,10 @@ module Commands
29
29
  options[:tag] = v
30
30
  end
31
31
 
32
+ opts.on("--remote_version", "Pull from remote version branch into your current branch.") do |v|
33
+ options[:remote_version] = v
34
+ end
35
+
32
36
  end
33
37
 
34
38
  def run(global_options)
@@ -36,10 +40,14 @@ module Commands
36
40
  # see if we can open the config file - we append the .config suffix
37
41
  # the file is expected to be in JSON format
38
42
  tag = options[:tag]
39
- force = options[:force]
43
+ remote_version = options[:remote_version]
40
44
 
41
45
  if ARGV.length > 0
42
- raise "You must specify all arguments with their options. You probably meant to use -b for the branch"
46
+ raise "You must specify all arguments with their options."
47
+ end
48
+
49
+ if (!tag.nil? && !remote_version.nil?)
50
+ raise "You can't specify both a pull from a tag and a pull from a remote version branch together."
43
51
  end
44
52
 
45
53
  # determine config_name by extracting parent of our directory
@@ -56,6 +64,7 @@ module Commands
56
64
  if repo[:create_dev_branch]
57
65
  repo_name = EbmSharedLib.get_repo_name(repo[:git_path])
58
66
  repo_path = "#{top_dir}/#{repo_name}"
67
+ branch = repo[:branch]
59
68
  puts("\n#{repo_name} pull:\n");
60
69
 
61
70
  cmd = "git fetch --all"
@@ -70,8 +79,13 @@ module Commands
70
79
  raise "Git checkout failed for #{repo_name}."
71
80
  end
72
81
  else
73
- # use a normal pull from the specified remote repo
74
- cmd = "git pull"
82
+ if remote_version
83
+ # pulling from remote version branch
84
+ cmd = "git pull origin #{branch}"
85
+ else
86
+ # pull from the remote branch of the current branch
87
+ cmd = "git pull"
88
+ end
75
89
  if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0
76
90
  raise "Git pull failed for #{repo_name}."
77
91
  end
data/lib/commands/tag.rb CHANGED
@@ -34,6 +34,10 @@ module Commands
34
34
  options[:delete] = v
35
35
  end
36
36
 
37
+ opts.on("--commit_and_push", "Commit any local changes and then push the remote - should only be used by the build system.") do |v|
38
+ options[:commit_and_push] = v
39
+ end
40
+
37
41
  end
38
42
 
39
43
  def run(global_options)
@@ -41,7 +45,12 @@ module Commands
41
45
  # see if we can open the config file - we append the .config suffix
42
46
  # the file is expected to be in JSON format
43
47
  tag = options[:tag]
44
- delete_tag = options[:delete]
48
+ delete_tag = !!options[:delete]
49
+ commit_and_push = !!options[:commit_and_push] # the !! forces conversion to a boolean
50
+
51
+ if (commit_and_push && delete_tag)
52
+ raise "You cannot use --commit_and_push with --delete."
53
+ end
45
54
 
46
55
  # determine config_name by extracting our directory
47
56
  config_name = EbmSharedLib.config_name_from_dir(Dir.pwd)
@@ -60,15 +69,34 @@ module Commands
60
69
  if repo[:taggable]
61
70
  repo_name = EbmSharedLib.get_repo_name(repo[:git_path])
62
71
  repo_path = "#{top_dir}/#{repo_name}"
63
- if delete_tag == true
72
+ if delete_tag
64
73
  cmd = "git tag -d #{tag} && git push origin :refs/tags/#{tag}"
65
74
  else
75
+ if commit_and_push
76
+ # they want to commit whatever has changed and push to current remote
77
+ # first grab the current branch name
78
+ cmd = "git symbolic-ref HEAD"
79
+ result = EbmSharedLib::CL.do_cmd_output(cmd, repo_path)
80
+ if $?.exitstatus != 0
81
+ raise "Unable to get the current branch for #{repo_name}, you may be on a detached HEAD."
82
+ end
83
+ branch = result.rstrip.split("/").last
84
+
85
+ # we have the local branch so now commit and push to the remote branch
86
+ cmd = "git commit -am \"Committing changes via ebm tag --commit_and_push for tag #{tag}.\""
87
+ EbmSharedLib::CL.do_cmd_result(cmd, repo_path) # ignore any error
88
+
89
+ # now push what we just committed
90
+ cmd = "git push origin #{branch}"
91
+ if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0
92
+ raise "Push failed failed for #{repo_name}."
93
+ end
94
+ end
66
95
  cmd = "git tag #{tag} && git push origin refs/tags/#{tag}"
96
+ if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0
97
+ raise "Tagging operation failed for #{repo_name}. Make sure you are in the top level #{config_name} directory."
98
+ end
67
99
  end
68
- if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0
69
- raise "Tagging operation failed for #{repo_name}. Make sure you are in the top level #{config_name} directory."
70
- end
71
-
72
100
  end
73
101
  end
74
102
 
@@ -40,6 +40,23 @@ module EbmSharedLib
40
40
  def self.do_cmd_result(cmd, dir=nil)
41
41
  do_cmd(cmd, dir)
42
42
  end
43
+
44
+ # run a command and return the output string
45
+ def self.do_cmd_output(cmd, dir=nil)
46
+ exit_code = 0
47
+ result = ""
48
+
49
+ if dir.nil? == false
50
+ Dir.chdir(dir){
51
+ result = `#{cmd}`
52
+ }
53
+ else
54
+ result = `#{cmd}`
55
+ end
56
+
57
+ result
58
+ end
59
+
43
60
  end
44
61
 
45
62
  def self.prepare_config_repo
data/lib/info.rb CHANGED
@@ -7,6 +7,6 @@
7
7
  #
8
8
  class Info
9
9
  def self.version
10
- "0.0.14"
10
+ "0.0.15"
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ebm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Seitz
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2013-06-25 00:00:00 Z
12
+ date: 2013-06-26 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: subcommand