nerdbank_gitversioning/cloud_build_services/
space_automation.rs1use std::io::{self, Write};
7
8use crate::cloud::{CloudBuild, EnvironmentVariables, empty_variables, env, if_starts_with};
9
10pub struct SpaceAutomation;
12
13impl CloudBuild for SpaceAutomation {
14 fn name(&self) -> &'static str {
15 "SpaceAutomation"
16 }
17
18 fn is_applicable(&self) -> bool {
19 self.git_commit_id().is_some()
20 }
21
22 fn is_pull_request(&self) -> bool {
23 false
24 }
25
26 fn building_branch(&self) -> Option<String> {
27 if_starts_with(env("JB_SPACE_GIT_BRANCH"), "refs/heads/")
28 }
29
30 fn building_tag(&self) -> Option<String> {
31 if_starts_with(env("JB_SPACE_GIT_BRANCH"), "refs/tags/")
32 }
33
34 fn git_commit_id(&self) -> Option<String> {
35 env("JB_SPACE_GIT_REVISION")
36 }
37
38 fn set_cloud_build_number(
39 &self,
40 _build_number: &str,
41 _stdout: &mut dyn Write,
42 _stderr: &mut dyn Write,
43 ) -> io::Result<EnvironmentVariables> {
44 Ok(empty_variables())
45 }
46
47 fn set_cloud_build_variable(
48 &self,
49 _name: &str,
50 _value: &str,
51 _stdout: &mut dyn Write,
52 _stderr: &mut dyn Write,
53 ) -> io::Result<EnvironmentVariables> {
54 Ok(empty_variables())
55 }
56}