ecb 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/commands/xcode_build.rb +128 -0
- data/lib/commands.rb +1 -0
- data/lib/ebmsharedlib/options.rb +1 -1
- data/lib/ebmsharedlib/utilities.rb +15 -18
- data/lib/ecb.rb +5 -4
- data/lib/info.rb +1 -1
- metadata +16 -12
- data/lib/commands/commit.rb +0 -91
- data/lib/commands/configs.rb +0 -58
- data/lib/commands/format_helper.rb +0 -106
- data/lib/commands/make_sample.rb +0 -85
- data/lib/commands/periodic.rb +0 -54
- data/lib/commands/prepare.rb +0 -191
- data/lib/commands/prune.rb +0 -53
- data/lib/commands/pull.rb +0 -140
- data/lib/commands/push.rb +0 -83
- data/lib/commands/remove_merged_branches.rb +0 -60
- data/lib/commands/tag.rb +0 -107
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1eb1dd0fb7b6ffe99523933ec0c13577f9460af
|
4
|
+
data.tar.gz: 3c6de04a3e02783c8b4162ac1b05137455967817
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e15c4f45993fab11a5372ff8b8975760d4fe62360cc2d981ddb96e12358478494f54fce11726df47f2e09ecce7052a7254cf0a94752ab538a4d13d76aa3d7e7
|
7
|
+
data.tar.gz: 1c9e6ce3c6019e57848b41f939220de8935de69978e8e3893face05afe2a5dc7daa991c854fd41eeef32b2b57dc607f6a772a4190bb3714a7b71345d9a6f994f
|
@@ -0,0 +1,128 @@
|
|
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 XcodeBuild
|
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
|
+
:branch
|
23
|
+
]
|
24
|
+
end
|
25
|
+
|
26
|
+
def register(opts, global_options)
|
27
|
+
opts.banner = "Usage: xcode_archive [options]"
|
28
|
+
opts.description = "Build an Xcode deliverable from the specified config."
|
29
|
+
|
30
|
+
opts.on('-c', "--config name", "Required - Name of the config we are building from.") do |v|
|
31
|
+
options[:config] = v
|
32
|
+
end
|
33
|
+
opts.on('-b', "--branch name", "Required - Name git branch that we are building from.") do |v|
|
34
|
+
options[:branch] = v
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on('-r', "--config-repo name", EcbSharedLib::REPO_COMMAND_DETAILS) do |v|
|
38
|
+
options[:config_repo] = v
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on('-a', "--archive archivePath", "Path to build the archive") do |v|
|
42
|
+
options[:archive] = v
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# prepare a single repo and create a local and tracking branch if it should have one
|
48
|
+
# if the repo specifies a branch then we will do the initial fetch from that branch
|
49
|
+
# if the create_dev_branch flag is set, we will create a local and tracking branch with
|
50
|
+
# the developer initials prepended
|
51
|
+
def do_build(build, archivePath, branch)
|
52
|
+
workspace = build[:workspace]
|
53
|
+
scheme = build[:scheme]
|
54
|
+
xcconfig = build[:xcconfig]
|
55
|
+
archiveName = build[:archiveName]
|
56
|
+
exportName = build[:exportName]
|
57
|
+
configuration = build[:configuration]
|
58
|
+
extra_configs = build[:extra_configs]
|
59
|
+
provisioning_file = build[:provisioning_file]
|
60
|
+
|
61
|
+
branchCmd = "git push --delete origin #{branch}"
|
62
|
+
|
63
|
+
if !archivePath.empty? then
|
64
|
+
archive = 'archive'
|
65
|
+
else
|
66
|
+
archive = ''
|
67
|
+
end
|
68
|
+
|
69
|
+
cmd = "xcodebuild #{archive} -workspace #{workspace} -scheme #{scheme} -xcconfig '#{xcconfig}' -configuration #{configuration} -derivedDataPath build -archivePath '#{archivePath}/#{archiveName}' #{extra_configs}"
|
70
|
+
if EcbSharedLib::CL.do_cmd_result(cmd, '.') != 0
|
71
|
+
EcbSharedLib::CL.do_cmd(branchCmd, '.')
|
72
|
+
raise "Xcode Build failed."
|
73
|
+
end
|
74
|
+
|
75
|
+
if !archivePath.empty? then
|
76
|
+
cmd = "xcodebuild -exportArchive -exportFormat IPA -archivePath '#{archivePath}/#{archiveName}' -exportPath '#{archivePath}/#{exportName}' -exportProvisioningProfile '#{provisioning_file}'"
|
77
|
+
if EcbSharedLib::CL.do_cmd_result(cmd, '.') != 0
|
78
|
+
EcbSharedLib::CL.do_cmd(branchCmd, '.')
|
79
|
+
raise "Xcode Export Arcive failed."
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def run(global_options)
|
85
|
+
# see if we can open the config file - we append the .config suffix
|
86
|
+
# the file is expected to be in JSON format
|
87
|
+
config_name = options[:config]
|
88
|
+
archivePath = options[:archive]
|
89
|
+
branch = options[:branch]
|
90
|
+
|
91
|
+
config_repo = options[:config_repo]
|
92
|
+
config_repo_url = EcbSharedLib.prepare_config_repo(config_repo)
|
93
|
+
info = EcbSharedLib.read_repo_config(config_repo_url, config_name)
|
94
|
+
|
95
|
+
# Now that we have the json, prepare the world by creating a directory with the config name and placing
|
96
|
+
# the various repos beneath that. The directory is created relative to the current directory.
|
97
|
+
|
98
|
+
cmd = "rm -Rf build"
|
99
|
+
EcbSharedLib::CL.do_cmd(cmd, '.')
|
100
|
+
|
101
|
+
if !archivePath.empty? then
|
102
|
+
cmd = "rm -Rf #{archivePath}"
|
103
|
+
EcbSharedLib::CL.do_cmd(cmd, '.')
|
104
|
+
end
|
105
|
+
|
106
|
+
builds = info[:builds]
|
107
|
+
builds.each do |build|
|
108
|
+
do_build(build, archivePath, branch)
|
109
|
+
cmd = "git checkout ."
|
110
|
+
EcbSharedLib::CL.do_cmd(cmd, '.')
|
111
|
+
end
|
112
|
+
|
113
|
+
# finish up by writing settings
|
114
|
+
settings = {
|
115
|
+
:config_repo_url => config_repo_url,
|
116
|
+
:config_name => config_name,
|
117
|
+
}
|
118
|
+
|
119
|
+
# saves the settings to .ecb-settings.json file.
|
120
|
+
# currently inside a git repo, which is probably not the desired behavior.
|
121
|
+
# don't think this is needed for ecb.
|
122
|
+
|
123
|
+
#top_dir = "#{Dir.pwd}/#{config_name}"
|
124
|
+
#EcbSharedLib.write_settings(settings, top_dir, err_msg = nil)
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
data/lib/commands.rb
CHANGED
data/lib/ebmsharedlib/options.rb
CHANGED
@@ -5,17 +5,16 @@
|
|
5
5
|
# All rights reserved.
|
6
6
|
# http://www.ebay.com
|
7
7
|
#
|
8
|
-
module
|
9
|
-
ROOT_PATH = File.expand_path("~/.
|
10
|
-
CONFIG_DIR = "
|
8
|
+
module EcbSharedLib
|
9
|
+
ROOT_PATH = File.expand_path("~/.ecb")
|
10
|
+
CONFIG_DIR = "buildsys_configs"
|
11
11
|
CONFIG_SUFFIX = ".config"
|
12
|
-
SETTINGS_FILE = ".
|
12
|
+
SETTINGS_FILE = ".ecb-settings.json"
|
13
13
|
REPO_COMMAND_DETAILS = "Remote git repository for initial configs file download [mobi,corp,stash,<git url>]"
|
14
14
|
|
15
15
|
# the key is the shortcut used for the config repos
|
16
16
|
CONFIG_REPOS = {
|
17
|
-
"
|
18
|
-
"mobi" => "git@github.mobiebay.com:eBayMobile/build_configs.git",
|
17
|
+
"mobi" => "git@github.mobiebay.com:eBayMobile/buildsys_config.git",
|
19
18
|
}
|
20
19
|
CONFIG_REPOS["default"] = CONFIG_REPOS["mobi"]
|
21
20
|
|
@@ -69,7 +68,7 @@ module EbmSharedLib
|
|
69
68
|
# run a command and don't consider it an error
|
70
69
|
# if output contains string
|
71
70
|
def self.do_cmd_ignore_str(cmd, ok_match, dir=nil)
|
72
|
-
msg =
|
71
|
+
msg = EcbSharedLib::CL.do_cmd_output(cmd, dir)
|
73
72
|
puts msg
|
74
73
|
exit_code = $?.exitstatus
|
75
74
|
if exit_code != 0
|
@@ -118,7 +117,7 @@ module EbmSharedLib
|
|
118
117
|
# returns the full repo_url
|
119
118
|
def self.prepare_config_repo(config_repo_url)
|
120
119
|
# get the full url
|
121
|
-
repo_url =
|
120
|
+
repo_url = EcbSharedLib.get_config_repo_url(config_repo_url)
|
122
121
|
|
123
122
|
# get the local config dir
|
124
123
|
base_config_path = base_config_path(repo_url)
|
@@ -131,14 +130,13 @@ module EbmSharedLib
|
|
131
130
|
|
132
131
|
# try to pull, if it fails could be due to repo not cloned
|
133
132
|
cmd = "git pull"
|
134
|
-
if
|
133
|
+
if EcbSharedLib::CL.do_cmd_result(cmd, config_path) != 0
|
135
134
|
# pull failed, try to clone
|
136
135
|
cmd = "git clone #{repo_url} #{CONFIG_DIR}"
|
137
|
-
if
|
136
|
+
if EcbSharedLib::CL.do_cmd_result(cmd, base_config_path) != 0
|
138
137
|
raise "Unable to clone #{CONFIG_DIR} repo into #{base_config_path}"
|
139
138
|
end
|
140
139
|
end
|
141
|
-
|
142
140
|
repo_url
|
143
141
|
end
|
144
142
|
|
@@ -169,15 +167,14 @@ module EbmSharedLib
|
|
169
167
|
|
170
168
|
# write the prepared settings, expects us to pass
|
171
169
|
# dir to write into
|
172
|
-
def self.write_settings(map,
|
170
|
+
def self.write_settings(map,dir,err_msg = nil)
|
173
171
|
settings_path = "#{dir}/#{SETTINGS_FILE}"
|
174
|
-
write_json_file(map,
|
172
|
+
write_json_file(map,settings_path, err_msg)
|
175
173
|
end
|
176
174
|
|
177
175
|
# read and return the config info for this repo
|
178
176
|
def self.read_repo_config(repo_url, config_name, err_msg = nil)
|
179
|
-
config_file_path = "#{full_config_path(repo_url)}/configs/#{config_name}#{
|
180
|
-
|
177
|
+
config_file_path = "#{full_config_path(repo_url)}/configs/#{config_name}#{EcbSharedLib::CONFIG_SUFFIX}"
|
181
178
|
read_json_file(config_file_path, err_msg)
|
182
179
|
end
|
183
180
|
|
@@ -205,10 +202,10 @@ module EbmSharedLib
|
|
205
202
|
|
206
203
|
# get the current banch
|
207
204
|
def self.get_current_branch(repo, repo_path)
|
208
|
-
repo_name =
|
205
|
+
repo_name = EcbSharedLib.get_repo_name(repo[:git_path])
|
209
206
|
|
210
207
|
cmd = "git symbolic-ref HEAD"
|
211
|
-
result =
|
208
|
+
result = EcbSharedLib::CL.do_cmd_output(cmd, repo_path)
|
212
209
|
if $?.exitstatus != 0
|
213
210
|
raise "Unable to get the current branch for #{repo_name}, you may be on a detached HEAD."
|
214
211
|
end
|
@@ -221,7 +218,7 @@ module EbmSharedLib
|
|
221
218
|
begin
|
222
219
|
# for now we still operate without settings by using defaults
|
223
220
|
# this should be removed once everyone is on the new tool
|
224
|
-
settings = read_settings(".
|
221
|
+
settings = read_settings(".ecb-settings not found, make sure you are in the top level directory.")
|
225
222
|
repo_url = settings[:config_repo_url]
|
226
223
|
config_name = settings[:config_name]
|
227
224
|
rescue
|
data/lib/ecb.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
require "fileutils"
|
10
10
|
require "pathname"
|
11
|
-
require 'plist'
|
11
|
+
#require 'plist'
|
12
12
|
|
13
13
|
$:.unshift(File.dirname(__FILE__))
|
14
14
|
models = File.expand_path('../../models', __FILE__)
|
@@ -38,7 +38,7 @@ class Ecb
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def printer
|
41
|
-
|
41
|
+
EcbSharedLib.printer
|
42
42
|
end
|
43
43
|
|
44
44
|
# define sub commands here
|
@@ -46,6 +46,7 @@ class Ecb
|
|
46
46
|
sub_commands[:version] = Commands::Version.new
|
47
47
|
sub_commands[:randombranch] = Commands::RandomBranch.new
|
48
48
|
sub_commands[:update_plist] = Commands::UpdatePlist.new
|
49
|
+
sub_commands[:xcode_build] = Commands::XcodeBuild.new
|
49
50
|
end
|
50
51
|
|
51
52
|
def setup
|
@@ -119,8 +120,8 @@ class Ecb
|
|
119
120
|
validate(cmd, sub_cmd)
|
120
121
|
|
121
122
|
# track both types of options
|
122
|
-
|
123
|
-
|
123
|
+
EcbSharedLib::Options.global_options = options
|
124
|
+
EcbSharedLib::Options.cmd_options = sub_cmd.options
|
124
125
|
|
125
126
|
sub_cmd.send("run", options)
|
126
127
|
end
|
data/lib/info.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick Hoiberg
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.6.12
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: plist
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.1.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.1.0
|
69
83
|
description: Various utility commands for building eBay mobile Core
|
70
84
|
email:
|
71
85
|
executables:
|
@@ -73,20 +87,10 @@ executables:
|
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
|
-
- lib/commands/commit.rb
|
77
|
-
- lib/commands/configs.rb
|
78
|
-
- lib/commands/format_helper.rb
|
79
|
-
- lib/commands/make_sample.rb
|
80
|
-
- lib/commands/periodic.rb
|
81
|
-
- lib/commands/prepare.rb
|
82
|
-
- lib/commands/prune.rb
|
83
|
-
- lib/commands/pull.rb
|
84
|
-
- lib/commands/push.rb
|
85
90
|
- lib/commands/randombranch.rb
|
86
|
-
- lib/commands/remove_merged_branches.rb
|
87
|
-
- lib/commands/tag.rb
|
88
91
|
- lib/commands/update_plist.rb
|
89
92
|
- lib/commands/version.rb
|
93
|
+
- lib/commands/xcode_build.rb
|
90
94
|
- lib/commands.rb
|
91
95
|
- lib/ebmsharedlib/monkey_patches.rb
|
92
96
|
- lib/ebmsharedlib/options.rb
|
data/lib/commands/commit.rb
DELETED
@@ -1,91 +0,0 @@
|
|
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
|
data/lib/commands/configs.rb
DELETED
@@ -1,58 +0,0 @@
|
|
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
|
@@ -1,106 +0,0 @@
|
|
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
|
data/lib/commands/make_sample.rb
DELETED
@@ -1,85 +0,0 @@
|
|
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
|