File tree 3 files changed +26
-5
lines changed
3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -76,3 +76,7 @@ ENTRYPOINT ["./.controlplane/entrypoint.sh"]
76
76
# Default args to pass to the entry point that can be overridden
77
77
# For Kubernetes and ControlPlane, these are the "workload args"
78
78
CMD ["./bin/rails" , "server" ]
79
+
80
+ # Current commit hash environment variable
81
+ ARG GIT_COMMIT_SHA
82
+ ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
Original file line number Diff line number Diff line change @@ -5,7 +5,9 @@ class GitCommitSha
5
5
attr_writer :current_sha
6
6
7
7
def self . current_sha
8
- @current_sha ||= retrieve_sha_from_file . presence || retrieve_sha_from_git
8
+ @current_sha ||= ENV [ "GIT_COMMIT_SHA" ] . presence ||
9
+ retrieve_sha_from_file . presence ||
10
+ retrieve_sha_from_git
9
11
end
10
12
11
13
def self . reset_current_sha
Original file line number Diff line number Diff line change 17
17
GitCommitSha . reset_current_sha
18
18
end
19
19
20
- context "when .source_version file does not exist " do
21
- let ( :sha ) { "94d92356828a56db25fccff9d50f41c525eead5x " }
20
+ context "when GIT_COMMIT_SHA env var exists " do
21
+ let ( :sha ) { "94d92356828a56db25fccff9d50f41c525eead5z " }
22
22
let ( :expected_text ) { "94d9235" }
23
23
24
24
before do
25
- # stub this method since we need to control what the sha actually is
26
- allow ( GitCommitSha ) . to receive ( :retrieve_sha_from_git ) { sha }
25
+ ENV [ "GIT_COMMIT_SHA" ] = sha
26
+ end
27
+
28
+ after do
29
+ ENV . delete ( "GIT_COMMIT_SHA" )
27
30
end
28
31
29
32
it_behaves_like "Git Commit SHA"
39
42
40
43
it_behaves_like "Git Commit SHA"
41
44
end
45
+
46
+ context "when falling back to git command" do
47
+ let ( :sha ) { "94d92356828a56db25fccff9d50f41c525eead5x" }
48
+ let ( :expected_text ) { "94d9235" }
49
+
50
+ before do
51
+ # stub this method since we need to control what the sha actually is
52
+ allow ( GitCommitSha ) . to receive ( :retrieve_sha_from_git ) { sha }
53
+ end
54
+
55
+ it_behaves_like "Git Commit SHA"
56
+ end
42
57
end
You can’t perform that action at this time.
0 commit comments