ebm 0.0.15 → 0.0.16

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
- SHA512:
3
- metadata.gz: f7b603272b2c9fc59edce589b9c11b4e5782d1edcf898b396e15f3fef9fb7dbbbd0fea03e9d0483bef301e96e8fc4dac1a03d530c99a37bb518946b850ae73d9
4
- data.tar.gz: 00de09579c0f9729536c6c63e613b3ec6014e07421ec518610379cc9e8165c4a3a0168356c681e4f0e436ec4eb2460676e3309321e8d32cb01128b1266dcf5a4
5
2
  SHA1:
6
- metadata.gz: c749515fc92f8758856798292830057d2299b95c
7
- data.tar.gz: 51601bc0d48c15c7b2b29e57e165a09f8c619f29
3
+ data.tar.gz: 367cd483688c378a1979e31d5a54c5ace5b147c4
4
+ metadata.gz: 49faf13adbf47da860c7f57af3f7fc34d7525422
5
+ SHA512:
6
+ data.tar.gz: 7ec095e60931d255776b90fca492af8f6910a3401e4fc9b17b2ea338d40433ff81724010ae4a73e7b3619b8734bae5ff78f1bbfdfe7decd3dbc155cf2a148a4d
7
+ metadata.gz: 40d95b1f00c62395c9bbd6af7224c9e158afca688e9073875bf89b86b9799b3e0c15000874bee290f5fdceb756f5b8737233abfb59722442de8d9d1320fb2813
@@ -0,0 +1,88 @@
1
+ #
2
+ # Greg Seitz
3
+ #
4
+ # Copyright 2013, eBay Inc.
5
+ # All rights reserved.
6
+ # http://www.ebay.com
7
+ #
8
+ module Commands
9
+ class Commit
10
+
11
+ # holds the options that were passed
12
+ # you can set any initial defaults here
13
+ def options
14
+ @options ||= {
15
+ }
16
+ end
17
+
18
+ # required options
19
+ def required_options
20
+ @required_options ||= Set.new [
21
+ :comment
22
+ ]
23
+ end
24
+
25
+ def register(opts, global_options)
26
+ opts.banner = "Usage: commit [options]"
27
+ opts.description = "Commit changes to local repos."
28
+
29
+ opts.on('-c', "--comment comment", "Required - The comment you want to use for the commit.") do |v|
30
+ options[:comment] = v
31
+ end
32
+
33
+ opts.on("--add", "Also add all new files.") do |v|
34
+ options[:add] = v
35
+ end
36
+ end
37
+
38
+ def run(global_options)
39
+
40
+ # see if we can open the config file - we append the .config suffix
41
+ # the file is expected to be in JSON format
42
+ comment = options[:comment]
43
+ add = !!options[:add]
44
+
45
+ if ARGV.length > 0
46
+ raise "You must specify all arguments with their options."
47
+ end
48
+
49
+ # get config based on name of current dir
50
+ info = EbmSharedLib.get_config_from_top_dir(false)
51
+
52
+ # Back up to version parent dir. This directory contains the top level repos.
53
+ top_dir = Dir.pwd
54
+
55
+ repos = info[:repos]
56
+ repos.each do |repo|
57
+ if repo[:create_dev_branch]
58
+ repo_name = EbmSharedLib.get_repo_name(repo[:git_path])
59
+ repo_path = "#{top_dir}/#{repo_name}"
60
+ branch = repo[:branch]
61
+ puts("\n#{repo_name} commit:\n");
62
+
63
+ if (add)
64
+ # first add any new files
65
+ cmd = "git add ."
66
+ if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0
67
+ raise "Git add all failed for #{repo_name}."
68
+ end
69
+ end
70
+
71
+ cmd = "git commit -am \"#{comment}\""
72
+ msg = EbmSharedLib::CL.do_cmd_output(cmd, repo_path)
73
+ puts msg
74
+ exit_code = $?.exitstatus
75
+ if exit_code != 0
76
+ line = msg.split("\n").last # last line
77
+ # ugly hack to not show as error when nothing to commit
78
+ if line != "nothing to commit (working directory clean)"
79
+ raise "Git commit failed for #{repo_name}."
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ end
86
+
87
+ end
88
+ end
@@ -6,7 +6,7 @@
6
6
  # http://www.ebay.com
7
7
  #
8
8
  module Commands
9
- class ListConfigs
9
+ class Configs
10
10
 
11
11
  # holds the options that were passed
12
12
  # you can set any initial defaults here
@@ -22,17 +22,15 @@ module Commands
22
22
  end
23
23
 
24
24
  def register(opts, global_options)
25
- opts.banner = "Usage: list_configs"
26
- opts.description = "List all possible configurations."
25
+ opts.banner = "Usage: configs"
26
+ opts.description = "List all configurations."
27
27
  end
28
28
 
29
29
 
30
30
  def run(global_options)
31
- puts # add empty line
32
31
  # show contents of configs directory for files with .config extension
33
32
  # try to make sure the repo is available
34
33
  EbmSharedLib.prepare_config_repo
35
- info = EbmSharedLib.read_repo_config(config_name)
36
34
 
37
35
  config_path = "#{EbmSharedLib::CONFIG_PATH}/configs"
38
36
  config_names = Pathname.glob("#{config_path}/*.config").map { |file_info|
@@ -44,6 +42,7 @@ module Commands
44
42
  nil
45
43
  end
46
44
  }
45
+ puts "\nCurrent configurations:"
47
46
  config_names.each do |name|
48
47
  puts name unless name.nil?
49
48
  end
@@ -19,7 +19,6 @@ module Commands
19
19
  def required_options
20
20
  @required_options ||= Set.new [
21
21
  :config,
22
- :initials,
23
22
  ]
24
23
  end
25
24
 
@@ -31,7 +30,7 @@ module Commands
31
30
  options[:config] = v
32
31
  end
33
32
 
34
- opts.on('-i', "--initials name", "Required - Initials prepended to your branch For example --initials gws will result in something like gws_iphone_3.0.") do |v|
33
+ opts.on('-i', "--initials name", "Initials prepended to your branch For example --initials gws will result in something like gws_iphone_3.0.") do |v|
35
34
  options[:initials] = v
36
35
  end
37
36
 
@@ -120,7 +119,15 @@ module Commands
120
119
  # the file is expected to be in JSON format
121
120
  config_name = options[:config]
122
121
  initials = options[:initials]
123
- nobranch = options[:nobranch]
122
+ nobranch = !!options[:nobranch]
123
+
124
+ if (nobranch && initials)
125
+ raise "You must specify either the --initials or --nobranch, not both."
126
+ end
127
+
128
+ if (initials.nil? && nobranch == false)
129
+ raise "You must specify either --initials or --nobranch"
130
+ end
124
131
 
125
132
  # try to make sure the repo is available
126
133
  EbmSharedLib.prepare_config_repo
data/lib/commands/pull.rb CHANGED
@@ -23,7 +23,7 @@ module Commands
23
23
 
24
24
  def register(opts, global_options)
25
25
  opts.banner = "Usage: pull [options]"
26
- opts.description = "Prepare your build environment"
26
+ opts.description = "Pull code from remote repo."
27
27
 
28
28
  opts.on('-t', "--tag name", "Name of the remote tag that you want to checkout. Warning this will overwrite any local changes.") do |v|
29
29
  options[:tag] = v
@@ -50,12 +50,9 @@ module Commands
50
50
  raise "You can't specify both a pull from a tag and a pull from a remote version branch together."
51
51
  end
52
52
 
53
- # determine config_name by extracting parent of our directory
54
- config_name = EbmSharedLib.config_name_from_dir(Dir.pwd)
53
+ # get config based on name of current dir
54
+ info = EbmSharedLib.get_config_from_top_dir(false)
55
55
 
56
- # try to make sure the repo is available
57
- EbmSharedLib.prepare_config_repo
58
- info = EbmSharedLib.read_repo_config(config_name, "Config not found, make sure you are in the top level version directory.")
59
56
  # Back up to version parent dir. This directory contains the top level repos.
60
57
  top_dir = Dir.pwd
61
58
 
@@ -81,10 +78,10 @@ module Commands
81
78
  else
82
79
  if remote_version
83
80
  # pulling from remote version branch
84
- cmd = "git pull origin #{branch}"
81
+ cmd = "git pull --no-edit --recurse-submodules=yes origin #{branch}"
85
82
  else
86
83
  # pull from the remote branch of the current branch
87
- cmd = "git pull"
84
+ cmd = "git pull --no-edit --recurse-submodules=yes"
88
85
  end
89
86
  if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0
90
87
  raise "Git pull failed for #{repo_name}."
@@ -0,0 +1,78 @@
1
+ #
2
+ # Greg Seitz
3
+ #
4
+ # Copyright 2013, eBay Inc.
5
+ # All rights reserved.
6
+ # http://www.ebay.com
7
+ #
8
+ module Commands
9
+ class Push
10
+
11
+ # holds the options that were passed
12
+ # you can set any initial defaults here
13
+ def options
14
+ @options ||= {
15
+ }
16
+ end
17
+
18
+ # required options
19
+ def required_options
20
+ @required_options ||= Set.new [
21
+ ]
22
+ end
23
+
24
+ def register(opts, global_options)
25
+ opts.banner = "Usage: push [options]"
26
+ opts.description = "Push code to the remote repo."
27
+
28
+ opts.on("--remote_version", "Push from your local dev branch to the remote version branch - use with caution!") do |v|
29
+ options[:remote_version] = v
30
+ end
31
+
32
+ end
33
+
34
+ def run(global_options)
35
+
36
+ # see if we can open the config file - we append the .config suffix
37
+ # the file is expected to be in JSON format
38
+ remote_version = options[:remote_version]
39
+
40
+ if ARGV.length > 0
41
+ raise "You must specify all arguments with their options."
42
+ end
43
+
44
+ # get config based on name of current dir
45
+ info = EbmSharedLib.get_config_from_top_dir(false)
46
+
47
+ # Back up to version parent dir. This directory contains the top level repos.
48
+ top_dir = Dir.pwd
49
+
50
+ repos = info[:repos]
51
+ repos.each do |repo|
52
+ if repo[:create_dev_branch]
53
+ repo_name = EbmSharedLib.get_repo_name(repo[:git_path])
54
+ repo_path = "#{top_dir}/#{repo_name}"
55
+ local_branch = EbmSharedLib.get_current_branch(repo, repo_path)
56
+
57
+ puts("\n#{repo_name} push:\n");
58
+
59
+ if remote_version
60
+ # pulling from remote version branch
61
+ remote_branch = repo[:branch]
62
+ cmd = "git push origin #{local_branch}:#{remote_branch}"
63
+ else
64
+ # pull from the remote branch of the current branch
65
+ # they want to commit whatever has changed and push to current remote
66
+ # first grab the current branch name
67
+ cmd = "git push origin #{local_branch}"
68
+ end
69
+ if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0
70
+ raise "Git push failed for #{repo_name}."
71
+ end
72
+ end
73
+ end
74
+
75
+ end
76
+
77
+ end
78
+ end
@@ -23,7 +23,7 @@ module Commands
23
23
 
24
24
  def register(opts, global_options)
25
25
  opts.banner = "Usage: status"
26
- opts.description = "Shows the git status of all repos in the config. Expects to be called from within a top level repo."
26
+ opts.description = "Shows the git status of all repos in the config."
27
27
 
28
28
  end
29
29
 
@@ -33,15 +33,7 @@ module Commands
33
33
  # the file is expected to be in JSON format
34
34
 
35
35
  # determine config_name by extracting parent of our directory
36
- config_name = EbmSharedLib.config_name_from_dir(Dir.pwd)
37
- # config_name = "#{Dir.pwd}".split("/")[-2]
38
- # if config_name.nil?
39
- # raise "No version directory found. This command must be run from the top level directory (i.e. iphone_3.1)."
40
- # end
41
-
42
- # try to make sure the repo is available
43
- EbmSharedLib.prepare_config_repo
44
- info = EbmSharedLib.read_repo_config(config_name, "Config not found, make sure you are in the top level version directory.")
36
+ info = EbmSharedLib.get_config_from_top_dir(false)
45
37
 
46
38
  # Back up to version parent dir. This directory contains the top level repos.
47
39
  # top_dir = File.expand_path("#{Dir.pwd}/..")
data/lib/commands/tag.rb CHANGED
@@ -52,12 +52,7 @@ module Commands
52
52
  raise "You cannot use --commit_and_push with --delete."
53
53
  end
54
54
 
55
- # determine config_name by extracting our directory
56
- config_name = EbmSharedLib.config_name_from_dir(Dir.pwd)
57
-
58
- # try to make sure the repo is available
59
- EbmSharedLib.prepare_config_repo
60
- info = EbmSharedLib.read_repo_config(config_name)
55
+ info = EbmSharedLib.get_config_from_top_dir(false)
61
56
 
62
57
  # other than prepare, any commands that work across the repos expect you to start
63
58
  # in the containing directory (i.e. if your config is named iphone_3.1, you are expected
@@ -75,12 +70,7 @@ module Commands
75
70
  if commit_and_push
76
71
  # they want to commit whatever has changed and push to current remote
77
72
  # 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
73
+ branch = EbmSharedLib.get_current_branch(repo, repo_path)
84
74
 
85
75
  # we have the local branch so now commit and push to the remote branch
86
76
  cmd = "git commit -am \"Committing changes via ebm tag --commit_and_push for tag #{tag}.\""
data/lib/commands.rb CHANGED
@@ -15,9 +15,11 @@ require "ebmsharedlib/utilities"
15
15
 
16
16
 
17
17
  require 'commands/prepare'
18
- require 'commands/list_configs'
18
+ require 'commands/configs'
19
19
  require 'commands/make_sample'
20
20
  require 'commands/tag'
21
21
  require 'commands/status'
22
22
  require 'commands/periodic'
23
23
  require 'commands/pull'
24
+ require 'commands/push'
25
+ require 'commands/commit'
data/lib/ebm.rb CHANGED
@@ -44,12 +44,14 @@ class Ebm
44
44
  # define sub commands here
45
45
  def define_sub_commands
46
46
  sub_commands[:prepare] = Commands::Prepare.new
47
- sub_commands[:list_configs] = Commands::ListConfigs.new
47
+ sub_commands[:configs] = Commands::Configs.new
48
48
  sub_commands[:make_sample] = Commands::MakeSample.new
49
49
  sub_commands[:tag] = Commands::Tag.new
50
50
  sub_commands[:status] = Commands::Status.new
51
51
  sub_commands[:periodic] = Commands::Periodic.new
52
52
  sub_commands[:pull] = Commands::Pull.new
53
+ sub_commands[:push] = Commands::Push.new
54
+ sub_commands[:commit] = Commands::Commit.new
53
55
  end
54
56
 
55
57
  def setup
@@ -46,6 +46,7 @@ module EbmSharedLib
46
46
  exit_code = 0
47
47
  result = ""
48
48
 
49
+ puts cmd
49
50
  if dir.nil? == false
50
51
  Dir.chdir(dir){
51
52
  result = `#{cmd}`
@@ -104,4 +105,25 @@ module EbmSharedLib
104
105
  @printer ||= Printer.new
105
106
  end
106
107
 
108
+ # get the current banch
109
+ def self.get_current_branch(repo, repo_path)
110
+ repo_name = EbmSharedLib.get_repo_name(repo[:git_path])
111
+
112
+ cmd = "git symbolic-ref HEAD"
113
+ result = EbmSharedLib::CL.do_cmd_output(cmd, repo_path)
114
+ if $?.exitstatus != 0
115
+ raise "Unable to get the current branch for #{repo_name}, you may be on a detached HEAD."
116
+ end
117
+ branch = result.rstrip.split("/").last
118
+ end
119
+
120
+ def self.get_config_from_top_dir(prepare)
121
+ # determine config_name by extracting parent of our directory
122
+ config_name = EbmSharedLib.config_name_from_dir(Dir.pwd)
123
+
124
+ # try to make sure the repo is available
125
+ EbmSharedLib.prepare_config_repo if (prepare)
126
+
127
+ info = EbmSharedLib.read_repo_config(config_name, "Config not found, make sure you are in the top level version directory.")
128
+ end
107
129
  end
data/lib/info.rb CHANGED
@@ -7,6 +7,6 @@
7
7
  #
8
8
  class Info
9
9
  def self.version
10
- "0.0.15"
10
+ "0.0.16"
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.15
4
+ version: 0.0.16
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-26 00:00:00 Z
12
+ date: 2013-06-27 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: subcommand
@@ -50,11 +50,13 @@ extensions: []
50
50
  extra_rdoc_files: []
51
51
 
52
52
  files:
53
- - lib/commands/list_configs.rb
53
+ - lib/commands/commit.rb
54
+ - lib/commands/configs.rb
54
55
  - lib/commands/make_sample.rb
55
56
  - lib/commands/periodic.rb
56
57
  - lib/commands/prepare.rb
57
58
  - lib/commands/pull.rb
59
+ - lib/commands/push.rb
58
60
  - lib/commands/status.rb
59
61
  - lib/commands/tag.rb
60
62
  - lib/commands.rb