Skip to content

Commit 976e296

Browse files
committed
dynamically get the git revision
1 parent 73f31ef commit 976e296

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

tools/fastlane-plugin/spec/send_build_to_bugsnag_spec.rb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
BuildAction = Fastlane::Actions::SendBuildToBugsnagAction
88
BUGSNAG_CLI_PATH = BugsnagCli.get_bundled_path
9+
GIT_REVISION = `git rev-parse HEAD`.strip
910

1011

1112
describe BuildAction do
@@ -15,7 +16,7 @@ def run_with args
1516

1617
context 'building an iOS project' do
1718
it 'detects default Info.plist file excluding test dirs' do
18-
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789AAA --version-name 2.0-other --bundle-version 22 --builder-name josh.edney --revision 3a30a510ba898341ff8631da49dc7021fb28c40e --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
19+
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789AAA --version-name 2.0-other --bundle-version 22 --builder-name josh.edney --revision #{GIT_REVISION} --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
1920
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
2021
run_with({})
2122
end
@@ -24,7 +25,7 @@ def run_with args
2425
it 'reads api key from legacy location' do
2526
# the API key is now in `bugsnag.apiKey`, it used to be in 'BugsnagAPIKey',
2627
# test this can be extracted correctly from the `ios_proj_legacy`
27-
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789BBB --version-name 4.0-project --bundle-version 44 --builder-name josh.edney --revision 3a30a510ba898341ff8631da49dc7021fb28c40e --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
28+
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789BBB --version-name 4.0-project --bundle-version 44 --builder-name josh.edney --revision #{GIT_REVISION} --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
2829
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj_legacy')) do
2930
run_with({})
3031
end
@@ -33,7 +34,7 @@ def run_with args
3334
context 'using default config_file option' do
3435
context 'override API key from config' do
3536
it 'reads API key from the api_key option' do
36-
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789FFF --version-name 2.0-other --bundle-version 22 --builder-name josh.edney --revision 3a30a510ba898341ff8631da49dc7021fb28c40e --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
37+
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789FFF --version-name 2.0-other --bundle-version 22 --builder-name josh.edney --revision #{GIT_REVISION} --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
3738
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
3839
run_with({
3940
api_key: '12345678901234567890123456789FFF'
@@ -42,7 +43,7 @@ def run_with args
4243
end
4344

4445
it 'uses input versions from options' do
45-
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789AAA --version-name 8.0.0 --bundle-version 800 --builder-name josh.edney --revision 3a30a510ba898341ff8631da49dc7021fb28c40e --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
46+
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789AAA --version-name 8.0.0 --bundle-version 800 --builder-name josh.edney --revision #{GIT_REVISION} --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
4647
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
4748
run_with({
4849
app_version: '8.0.0',
@@ -55,7 +56,7 @@ def run_with args
5556

5657
context 'override config_file option' do
5758
it 'reads API key and version info from the config file' do
58-
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789DDD --version-name 3.0-project --bundle-version 33 --builder-name josh.edney --revision 3a30a510ba898341ff8631da49dc7021fb28c40e --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
59+
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789DDD --version-name 3.0-project --bundle-version 33 --builder-name josh.edney --revision #{GIT_REVISION} --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
5960
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
6061
run_with({
6162
config_file: File.join('Project', 'Info.plist')
@@ -65,7 +66,7 @@ def run_with args
6566

6667
context 'override API key, and config file' do
6768
it 'uses the input api_key to override a non default config' do
68-
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789EEE --version-name 3.0-project --bundle-version 33 --builder-name josh.edney --revision 3a30a510ba898341ff8631da49dc7021fb28c40e --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
69+
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789EEE --version-name 3.0-project --bundle-version 33 --builder-name josh.edney --revision #{GIT_REVISION} --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
6970
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
7071
run_with({
7172
config_file: File.join('Project', 'Info.plist'),
@@ -75,7 +76,7 @@ def run_with args
7576
end
7677

7778
it 'uses the input versions to override a non default config' do
78-
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789DDD --version-name 9.0.0 --bundle-version 900 --builder-name josh.edney --revision 3a30a510ba898341ff8631da49dc7021fb28c40e --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
79+
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789DDD --version-name 9.0.0 --bundle-version 900 --builder-name josh.edney --revision #{GIT_REVISION} --repository https://github.com/bugsnag/bugsnag-dsym-upload").and_return(true)
7980
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
8081
run_with({
8182
config_file: File.join('Project', 'Info.plist'),
@@ -89,7 +90,7 @@ def run_with args
8990

9091
context 'metadata added to args' do
9192
it "single key:value pair added" do
92-
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789DDD --version-name 4.0-project --bundle-version 22 --builder-name josh.edney --revision 3a30a510ba898341ff8631da49dc7021fb28c40e --repository https://github.com/bugsnag/bugsnag-dsym-upload --metadata \"test1\": \"First test\"").and_return(true)
93+
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789DDD --version-name 4.0-project --bundle-version 22 --builder-name josh.edney --revision #{GIT_REVISION} --repository https://github.com/bugsnag/bugsnag-dsym-upload --metadata \"test1\": \"First test\"").and_return(true)
9394
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
9495
run_with({
9596
app_version: '4.0-project',
@@ -100,7 +101,7 @@ def run_with args
100101
end
101102

102103
it "multiple key:value pairs added" do
103-
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789DDD --version-name 4.0-project --bundle-version 22 --builder-name josh.edney --revision 3a30a510ba898341ff8631da49dc7021fb28c40e --repository https://github.com/bugsnag/bugsnag-dsym-upload --metadata \"test1\": \"First test\", \"test2\": \"Second test\", \"test3\": \"Third test\"").and_return(true)
104+
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789DDD --version-name 4.0-project --bundle-version 22 --builder-name josh.edney --revision #{GIT_REVISION} --repository https://github.com/bugsnag/bugsnag-dsym-upload --metadata \"test1\": \"First test\", \"test2\": \"Second test\", \"test3\": \"Third test\"").and_return(true)
104105
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
105106
run_with({
106107
app_version: '4.0-project',
@@ -111,7 +112,7 @@ def run_with args
111112
end
112113

113114
it "multiple key:value pairs added as a hash" do
114-
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789DDD --version-name 4.0-project --bundle-version 22 --builder-name josh.edney --revision 3a30a510ba898341ff8631da49dc7021fb28c40e --repository https://github.com/bugsnag/bugsnag-dsym-upload --metadata \"custom_field_1\"=\"value1\", \"custom_field_2\"=\"value2\"").and_return(true)
115+
expect(Kernel).to receive(:system).with("#{BUGSNAG_CLI_PATH} create-build --api-key 12345678901234567890123456789DDD --version-name 4.0-project --bundle-version 22 --builder-name josh.edney --revision #{GIT_REVISION} --repository https://github.com/bugsnag/bugsnag-dsym-upload --metadata \"custom_field_1\"=\"value1\", \"custom_field_2\"=\"value2\"").and_return(true)
115116
Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
116117
run_with({
117118
app_version: '4.0-project',

0 commit comments

Comments
 (0)