ecb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f42dfa6b6a572b6b964e0cb7eb14211c062e898a
4
+ data.tar.gz: 1b850e302822a3a92dd209d20585080f2b7a54f1
5
+ SHA512:
6
+ metadata.gz: 0e7d850184b3500cb7929f81e45a4d8cb2e964b5829284e9d8c349a9155b0dcf4756d758c54f18f3d1a9eb816b1ff79f5b55e36b8625860e73f985ba3b2e68c3
7
+ data.tar.gz: c7eaae920437caa761da826333f87952b30867edae96a3353fb7b72ea1cc858dd42acb1932b557ed584a7965240238bcd9ba417f22c5c6fee13b3cfed940c717
data/LICENSE ADDED
@@ -0,0 +1 @@
1
+ Copyright (c) 2013 eBay
data/bin/ecb ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Greg Seitz
4
+ #
5
+ # Copyright 2013, eBay Inc.
6
+ # All rights reserved.
7
+ # http://www.ebay.com
8
+ #
9
+ #
10
+ # ebm - Ebay Mobile Gem
11
+ # this command is meant to be called after installed as a gem
12
+ #
13
+
14
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
15
+ require 'rubygems'
16
+ #require "bundler/setup"
17
+ require 'ecb'
18
+
19
+ exit_code = Ecb.new.run
20
+ exit!(exit_code)
21
+
22
+
@@ -0,0 +1,22 @@
1
+ #
2
+ # Greg Seitz
3
+ #
4
+ # Copyright 2013, eBay Inc.
5
+ # All rights reserved.
6
+ # http://www.ebay.com
7
+ #
8
+ #require "FileUtils"
9
+ require "set"
10
+ require "fileutils"
11
+ require "hmac-sha1"
12
+ require 'securerandom'
13
+
14
+ require 'ebmsharedlib/monkey_patches'
15
+ require "printer"
16
+ require "ebmsharedlib/options"
17
+ require "ebmsharedlib/utilities"
18
+
19
+
20
+ require 'commands/version'
21
+ require 'commands/randombranch'
22
+ require 'commands/update_plist'
@@ -0,0 +1,91 @@
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 - alternate use -m.") do |v|
30
+ options[:comment] = v
31
+ end
32
+
33
+ opts.on('-m', "--comment comment", "Required - The comment you want to use for the commit - alternate use -c.") do |v|
34
+ options[:comment] = v
35
+ end
36
+
37
+ opts.on('-a', "--add", "Also add all new files.") do |v|
38
+ options[:add] = true
39
+ end
40
+
41
+ opts.on('-n', "--dry-run", "Perform a dry run.") do |v|
42
+ options[:dry_run] = v
43
+ end
44
+ end
45
+
46
+ def run(global_options)
47
+
48
+ # see if we can open the config file - we append the .config suffix
49
+ # the file is expected to be in JSON format
50
+ comment = options[:comment]
51
+ add = !!options[:add]
52
+ dry_run = !!options[:dry_run] ? "--dry-run" : ""
53
+
54
+ if ARGV.length > 0
55
+ raise "You must specify all arguments with their options."
56
+ end
57
+
58
+ # get config based on name of current dir
59
+ info = EbmSharedLib.get_config_from_top_dir
60
+
61
+ # Back up to version parent dir. This directory contains the top level repos.
62
+ top_dir = Dir.pwd
63
+
64
+ repos = info[:repos]
65
+ repos.each do |repo|
66
+ if repo[:create_dev_branch]
67
+ repo_name = EbmSharedLib.get_repo_name(repo[:git_path])
68
+ repo_path = "#{top_dir}/#{repo_name}"
69
+ branch = repo[:branch]
70
+ puts("\n#{repo_name} commit:\n");
71
+
72
+ if (add)
73
+ # first add any new files
74
+ cmd = "git add #{dry_run} ."
75
+ if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0
76
+ raise "Git add all failed for #{repo_name}."
77
+ end
78
+ end
79
+
80
+ cmd = "git commit #{dry_run} -am \"#{comment}\""
81
+ exit_code = EbmSharedLib::CL.do_cmd_ignore_str(cmd, "nothing to commit", repo_path)
82
+ if exit_code != 0 && exit_code != 999
83
+ raise "Git commit failed for #{repo_name}."
84
+ end
85
+ end
86
+ end
87
+
88
+ end
89
+
90
+ end
91
+ end
@@ -0,0 +1,58 @@
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 Configs
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: configs"
26
+ opts.description = "List all configurations."
27
+
28
+ opts.on('-r', "--config-repo name", EbmSharedLib::REPO_COMMAND_DETAILS) do |v|
29
+ options[:config_repo] = v
30
+ end
31
+ end
32
+
33
+
34
+ def run(global_options)
35
+ # show contents of configs directory for files with .config extension
36
+ # try to make sure the repo is available
37
+ config_repo = options[:config_repo]
38
+ repo_url = EbmSharedLib.prepare_config_repo(config_repo)
39
+
40
+ config_path = EbmSharedLib.full_config_path(repo_url)
41
+ config_names = Pathname.glob("#{config_path}/configs/*.config").map { |file_info|
42
+ if file_info.directory? == false
43
+ name = file_info.basename.to_s
44
+ name.slice!("#{EbmSharedLib::CONFIG_SUFFIX}")
45
+ name
46
+ else
47
+ nil
48
+ end
49
+ }
50
+ puts "\nCurrent configurations for #{repo_url}:"
51
+ config_names.each do |name|
52
+ puts name unless name.nil?
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,106 @@
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 FormatHelper
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: format_helper [options]"
26
+ opts.description = "Create checkouts and removes after format merge - only for android code reformat."
27
+ opts.on('-n', "--dry-run", "Perform a dry run.") do |v|
28
+ options[:dry_run] = true
29
+ end
30
+ end
31
+
32
+ # @param [Object] global_options
33
+ def run(global_options)
34
+
35
+ if ARGV.length > 0
36
+ raise "You must specify all arguments with their options."
37
+ end
38
+ dry_run = !!options[:dry_run]
39
+
40
+ # get config based on name of current dir
41
+ info = EbmSharedLib.get_config_from_top_dir
42
+
43
+ # Back up to version parent dir. This directory contains the top level repos.
44
+ top_dir = Dir.pwd
45
+
46
+ merge_failed = false
47
+ repos = info[:repos]
48
+ repos.each do |repo|
49
+ repo_name = EbmSharedLib.get_repo_name(repo[:git_path])
50
+ repo_path = "#{top_dir}/#{repo_name}"
51
+ branch = repo[:branch]
52
+ base_branch = repo[:base_branch]
53
+
54
+ puts("\n#{repo_name} format_helper:\n");
55
+
56
+ cmd = "git status --short"
57
+ result = EbmSharedLib::CL.do_cmd_output(cmd, repo_path)
58
+ if $?.exitstatus != 0
59
+ raise "Git status failed for #{repo_name}."
60
+ end
61
+
62
+ pairs = result.split
63
+
64
+ len = pairs.length
65
+ cur = 0
66
+ matches = 0
67
+ while true
68
+ if cur == len
69
+ break
70
+ end
71
+ code = pairs[cur]
72
+ cur += 1
73
+ path = pairs[cur]
74
+ cur += 1
75
+ if code == "UU"
76
+ matches +=1
77
+ #puts "#{code} - #{path}"
78
+ cmd = "git checkout --ours -- #{path}"
79
+ if dry_run
80
+ puts cmd
81
+ else
82
+ if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0
83
+ raise "Git checkout failed for #{path}."
84
+ end
85
+ cmd = "git add #{path}"
86
+ if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0
87
+ raise "Git add failed for #{path}."
88
+ end
89
+ end
90
+ elsif code == "DU"
91
+ matches += 1
92
+ cmd = "git rm #{path}"
93
+ if dry_run
94
+ puts cmd
95
+ else
96
+ if EbmSharedLib::CL.do_cmd_result(cmd, repo_path) != 0
97
+ raise "Git rm failed for #{path}."
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ end
106
+ end
@@ -0,0 +1,85 @@
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 MakeSample
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
+ :config,
22
+ ]
23
+ end
24
+
25
+ def register(opts, global_options)
26
+ opts.banner = "Usage: make_sample [options]"
27
+ opts.description = "Make a sample config file"
28
+
29
+ opts.on('-c', "--config name", "Required - Name of the config we are making.") do |v|
30
+ options[:config] = v
31
+ end
32
+
33
+ end
34
+
35
+
36
+ def run(global_options)
37
+
38
+ # create a sample config file in the current directory - we append the .config suffix
39
+ # the file will be in JSON format
40
+ config_name = options[:config]
41
+
42
+ config_path = "#{config_name}#{EbmSharedLib::CONFIG_SUFFIX}"
43
+
44
+ begin
45
+ sample = {
46
+ :repos => [
47
+ {
48
+ :branch => "iphone_3.1",
49
+ :create_dev_branch => true,
50
+ :git_path => "git@github.scm.corp.ebay.com:eBayMobile/ios_iphone_core.git",
51
+ :taggable => true,
52
+ },
53
+ {
54
+ :branch => "nautilus_3.1",
55
+ :create_dev_branch => true,
56
+ :git_path => "git@github.scm.corp.ebay.com:eBayMobile/ios_nautilus.git",
57
+ :taggable => true,
58
+ },
59
+ {
60
+ :tag => "2.2.9",
61
+ :git_path => "git@github.scm.corp.ebay.com:ios-mobile-framework/CoreFramework.git",
62
+ :parent_path => "Framework",
63
+ },
64
+ {
65
+ :tag => "2.0.10",
66
+ :git_path => "git@github.scm.corp.ebay.com:ios-mobile-framework/ImagePickerModule.git",
67
+ :parent_path => "Framework/Modules",
68
+ },
69
+ {
70
+ :tag => "11fb35782f647a13552ccbd620ca4e88b75a8977",
71
+ :git_path => "git@github.scm.corp.ebay.com:cfry/RegistrationModule.git",
72
+ :parent_path => "Framework/Modules",
73
+ },
74
+ ],
75
+ }
76
+
77
+ json = JSON.pretty_generate(sample)
78
+
79
+ File.open(config_path, 'w') { |file| file.write(json) }
80
+ rescue
81
+ raise "Error creating config file JSON: #{config_path}"
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,54 @@
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 Periodic
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
+ :command,
22
+ :interval
23
+ ]
24
+ end
25
+
26
+ def register(opts, global_options)
27
+ opts.banner = "Usage: periodic [options]"
28
+ opts.description = "Run a periodic command"
29
+
30
+ opts.on('-c', "--command name", "Required - Command to run.") do |v|
31
+ options[:command] = v
32
+ end
33
+
34
+ opts.on('-i', "--interval value", Integer, "Required - Interval in seconds.") do |v|
35
+ options[:interval] = v
36
+ end
37
+
38
+ end
39
+
40
+ def run(global_options)
41
+
42
+ # see if we can open the config file - we append the .config suffix
43
+ # the file is expected to be in JSON format
44
+ command = options[:command]
45
+ interval = options[:interval]
46
+
47
+ while true
48
+ EbmSharedLib::CL.do_cmd_result(command)
49
+ sleep(interval)
50
+ end
51
+ end
52
+
53
+ end
54
+ end