cumulusci-plus 5.0.16__py3-none-any.whl → 5.0.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cumulusci-plus might be problematic. Click here for more details.

cumulusci/__about__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "5.0.16"
1
+ __version__ = "5.0.17"
@@ -1,4 +1,5 @@
1
1
  import json
2
+ import logging
2
3
  import os
3
4
  from datetime import date
4
5
  from pathlib import Path
@@ -23,16 +24,12 @@ class EnvManagementOption(CCIOptions):
23
24
  )
24
25
  datatype: str = Field(
25
26
  default="string",
26
- description="The datatype of the environment variable. Defaults to string. Valid values are string, bool, int, float, date, list, dict, path, directory, filename, vcs_branch",
27
+ description="The datatype of the environment variable. Defaults to string. Valid values are string, bool, int, float, date, list, dict, path, directory, filename, vcs_repo",
27
28
  )
28
29
  set: bool = Field(
29
30
  default=False,
30
31
  description="If True, sets the value of the environment variable if it is not already set. Defaults to False",
31
32
  )
32
- url: str = Field(
33
- default="",
34
- description="The url of the repository to get the branch value from, Applicable only for vcs_branch datatype. Defaults to empty string",
35
- )
36
33
 
37
34
  @validator("datatype")
38
35
  def validate_datatype(cls, v):
@@ -47,62 +44,81 @@ class EnvManagementOption(CCIOptions):
47
44
  "path",
48
45
  "directory",
49
46
  "filename",
50
- "vcs_branch",
47
+ "vcs_repo",
51
48
  ]:
52
49
  raise ValueError(f"Invalid datatype: {v}")
53
50
  return v
54
51
 
55
52
  def formated_value(
56
53
  self,
54
+ task_values: dict[str, Any],
57
55
  project_config: Optional[BaseProjectConfig],
58
56
  org_config: Optional[OrgConfig],
59
- ) -> tuple[Any, str]:
57
+ logger: logging.Logger,
58
+ ) -> None:
60
59
  value = os.getenv(self.name, self.default)
61
60
  datatype = self.datatype or "string"
62
61
 
63
62
  try:
64
- match datatype:
65
- case "string":
66
- return str(value), str(value)
67
- case "bool":
68
- v = DummyValidatorModel(b=value).b
69
- return v, str(v)
70
- case "int":
71
- v = DummyValidatorModel(i=value).i
72
- return v, str(v)
73
- case "float":
74
- v = DummyValidatorModel(f=value).f
75
- return v, str(v)
76
- case "date":
77
- v = DummyValidatorModel(d=date.fromisoformat(str(value))).d
78
- return v, str(v)
79
- case "list":
80
- v = value if isinstance(value, list) else value.split(",")
81
- return v, str(v)
82
- case "dict":
83
- v = value if isinstance(value, dict) else json.loads(str(value))
84
- return v, str(v)
85
- case "path":
86
- v = Path(str(value))
87
- return v.absolute(), str(v.absolute())
88
- case "directory":
89
- v = Path(str(value)).parent.absolute()
90
- return v, str(v.absolute())
91
- case "filename":
92
- v = Path(str(value)).name
93
- return v, str(v)
94
- case "vcs_branch":
95
- task_config = TaskConfig({"options": {"url": self.url}})
96
- task = VcsRemoteBranch(project_config, task_config, org_config)
97
- result = task()
98
- return result["remote_branch"], str(result["remote_branch"])
99
- case _:
100
- raise ValueError(f"Invalid datatype: {datatype}")
63
+ if self.name not in task_values:
64
+ match datatype:
65
+ case "string":
66
+ task_values[self.name] = str(value)
67
+ case "bool":
68
+ v = DummyValidatorModel(b=value).b
69
+ task_values[self.name] = v
70
+ case "int":
71
+ v = DummyValidatorModel(i=value).i
72
+ task_values[self.name] = v
73
+ case "float":
74
+ v = DummyValidatorModel(f=value).f
75
+ task_values[self.name] = v
76
+ case "date":
77
+ v = DummyValidatorModel(d=date.fromisoformat(str(value))).d
78
+ task_values[self.name] = v
79
+ case "list":
80
+ v = value if isinstance(value, list) else value.split(",")
81
+ task_values[self.name] = v
82
+ case "dict":
83
+ v = value if isinstance(value, dict) else json.loads(str(value))
84
+ task_values[self.name] = v
85
+ case "path":
86
+ v = Path(str(value))
87
+ task_values[self.name] = v.absolute()
88
+ case "directory":
89
+ v = Path(str(value)).parent.absolute()
90
+ task_values[self.name] = v.absolute()
91
+ case "filename":
92
+ v = Path(str(value)).name
93
+ task_values[self.name] = v
94
+ case "vcs_repo":
95
+ task_config = TaskConfig(
96
+ {"options": {"url": self.default, "name": self.name}}
97
+ )
98
+ task = VcsRemoteBranch(project_config, task_config, org_config)
99
+ result = task()
100
+ task_values[self.name] = result["url"]
101
+ task_values[f"{self.name}_BRANCH"] = result["branch"]
102
+ case _:
103
+ raise ValueError(f"Invalid datatype: {datatype}")
104
+ else:
105
+ logger.info(f"Variable {self.name} already set. Skipping.")
106
+
101
107
  except Exception as e:
102
108
  raise ValueError(
103
109
  f"Formatting Error: {value} for datatype: {datatype} - {e}"
104
110
  )
105
111
 
112
+ if self.set and self.name not in os.environ:
113
+ os.environ[self.name] = str(task_values[self.name])
114
+
115
+ if (
116
+ self.set
117
+ and self.datatype == "vcs_repo"
118
+ and f"{self.name}_BRANCH" not in os.environ
119
+ ):
120
+ os.environ[f"{self.name}_BRANCH"] = str(task_values[f"{self.name}_BRANCH"])
121
+
106
122
 
107
123
  class DummyValidatorModel(BaseModel):
108
124
  b: Optional[bool]
@@ -124,11 +140,9 @@ class EnvManagement(BaseTask):
124
140
  self.return_values = {}
125
141
 
126
142
  for env_option in self.parsed_options.envs:
127
- self.return_values[env_option.name], str_value = env_option.formated_value(
128
- self.project_config, self.org_config
143
+ env_option.formated_value(
144
+ self.return_values, self.project_config, self.org_config, self.logger
129
145
  )
130
- if env_option.set and env_option.name not in os.environ:
131
- os.environ[env_option.name] = str_value
132
146
 
133
147
  return self.return_values
134
148
 
@@ -139,19 +153,38 @@ class VcsRemoteBranch(BaseTask):
139
153
  ...,
140
154
  description="Gets if the remote branch name exist with the same name in the remote repository.",
141
155
  )
156
+ name: str = Field(
157
+ ...,
158
+ description="The name of the environment variable.",
159
+ )
142
160
 
143
161
  parsed_options: Options
144
162
 
145
163
  def _run_task(self):
146
164
  self.return_values = {}
147
- # Get current branch name.
148
- local_branch = self.project_config.repo_branch
149
- repo = get_repo_from_url(self.project_config, self.parsed_options.url)
165
+
166
+ # Get current branch name. Based on Local Git Branch if not available from Environment Variable
167
+ local_branch = os.getenv(
168
+ f"{self.parsed_options.name}_BRANCH", self.project_config.repo_branch
169
+ )
170
+
171
+ # Get repository URL from Environment Variable
172
+ self.return_values["url"] = os.getenv(
173
+ self.parsed_options.name, self.parsed_options.url
174
+ )
175
+
176
+ repo = get_repo_from_url(self.project_config, self.return_values["url"])
150
177
 
151
178
  try:
152
179
  branch = repo.branch(local_branch)
153
- self.return_values["remote_branch"] = branch.name
180
+ self.logger.info(
181
+ f"Branch {local_branch} found in repository {self.return_values['url']}."
182
+ )
183
+ self.return_values["branch"] = branch.name
154
184
  except Exception:
155
- self.return_values["remote_branch"] = repo.default_branch
185
+ self.logger.warning(
186
+ f"Branch {local_branch} not found in repository {self.return_values['url']}. Using default branch {repo.default_branch}"
187
+ )
188
+ self.return_values["branch"] = repo.default_branch
156
189
 
157
190
  return self.return_values
@@ -18,7 +18,12 @@ class TestVcsRemoteBranch(unittest.TestCase):
18
18
  project_config = create_project_config()
19
19
  project_config.repo_info["branch"] = "feature/branch-1"
20
20
  task_config = TaskConfig(
21
- {"options": {"url": "https://github.com/TestOwner/TestRepo"}}
21
+ {
22
+ "options": {
23
+ "url": "https://github.com/TestOwner/TestRepo",
24
+ "name": "VCS_URL",
25
+ }
26
+ }
22
27
  )
23
28
 
24
29
  with patch(
@@ -32,14 +37,22 @@ class TestVcsRemoteBranch(unittest.TestCase):
32
37
 
33
38
  task = VcsRemoteBranch(project_config, task_config)
34
39
  task()
35
- self.assertEqual(task.return_values["remote_branch"], "feature/branch-1")
40
+ self.assertEqual(
41
+ task.return_values["url"], "https://github.com/TestOwner/TestRepo"
42
+ )
43
+ self.assertEqual(task.return_values["branch"], "feature/branch-1")
36
44
  repo_mock.branch.assert_called_once_with("feature/branch-1")
37
45
 
38
46
  def test_run_task_branch_not_exist(self):
39
47
  project_config = create_project_config()
40
48
  project_config.repo_info["branch"] = "feature/branch-1"
41
49
  task_config = TaskConfig(
42
- {"options": {"url": "https://github.com/TestOwner/TestRepo"}}
50
+ {
51
+ "options": {
52
+ "url": "https://github.com/TestOwner/TestRepo",
53
+ "name": "VCS_URL",
54
+ }
55
+ }
43
56
  )
44
57
 
45
58
  with patch(
@@ -52,7 +65,10 @@ class TestVcsRemoteBranch(unittest.TestCase):
52
65
 
53
66
  task = VcsRemoteBranch(project_config, task_config)
54
67
  task()
55
- self.assertEqual(task.return_values["remote_branch"], "main")
68
+ self.assertEqual(
69
+ task.return_values["url"], "https://github.com/TestOwner/TestRepo"
70
+ )
71
+ self.assertEqual(task.return_values["branch"], "main")
56
72
  repo_mock.branch.assert_called_once_with("feature/branch-1")
57
73
 
58
74
 
@@ -177,20 +193,21 @@ class TestEnvManagement(unittest.TestCase):
177
193
  task()
178
194
 
179
195
  @patch("cumulusci.tasks.utility.env_management.VcsRemoteBranch")
180
- def test_vcs_branch_datatype(self, vcs_mock):
181
- os.environ["TEST_VAR"] = "" # vcs_branch doesn't use env var
182
-
196
+ def test_vcs_repo_datatype(self, vcs_mock):
183
197
  vcs_instance_mock = vcs_mock.return_value
184
- vcs_instance_mock.return_value = {"remote_branch": "my-feature-branch"}
198
+ vcs_instance_mock.return_value = {
199
+ "url": "https://github.com/TestOwner/TestRepo",
200
+ "branch": "my-feature-branch",
201
+ }
185
202
 
186
203
  task_config = TaskConfig(
187
204
  {
188
205
  "options": {
189
206
  "envs": [
190
207
  {
191
- "name": "VCS_BRANCH",
192
- "datatype": "vcs_branch",
193
- "url": "https://github.com/TestOwner/TestRepo",
208
+ "name": "VCS_URL",
209
+ "datatype": "vcs_repo",
210
+ "default": "https://github.com/TestOwner/TestRepo",
194
211
  }
195
212
  ]
196
213
  }
@@ -199,7 +216,8 @@ class TestEnvManagement(unittest.TestCase):
199
216
  task = EnvManagement(self.project_config, task_config, self.org_config)
200
217
  result = task()
201
218
 
202
- self.assertEqual(result["VCS_BRANCH"], "my-feature-branch")
219
+ self.assertEqual(result["VCS_URL"], "https://github.com/TestOwner/TestRepo")
220
+ self.assertEqual(result["VCS_URL_BRANCH"], "my-feature-branch")
203
221
  vcs_mock.assert_called_once()
204
222
 
205
223
  @patch.dict(os.environ, {}, clear=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cumulusci-plus
3
- Version: 5.0.16
3
+ Version: 5.0.17
4
4
  Summary: Build and release tools for Salesforce developers
5
5
  Project-URL: Homepage, https://github.com/jorgesolebur/CumulusCI
6
6
  Project-URL: Changelog, https://cumulusci.readthedocs.io/en/stable/history.html
@@ -127,7 +127,7 @@ license](https://github.com/SFDO-Tooling/CumulusCI/blob/main/LICENSE)
127
127
  and is not covered by the Salesforce Master Subscription Agreement.
128
128
 
129
129
  <!-- Changelog -->
130
- ## v5.0.16 (2025-08-20)
130
+ ## v5.0.17 (2025-08-21)
131
131
 
132
132
  <!-- Release notes generated using configuration in .github/release.yml at main -->
133
133
 
@@ -135,6 +135,6 @@ and is not covered by the Salesforce Master Subscription Agreement.
135
135
 
136
136
  ### Changes
137
137
 
138
- - Add configure_env task and fix failing test classes. by [@rupeshjSFDC](https://github.com/rupeshjSFDC) in [#57](https://github.com/jorgesolebur/CumulusCI/pull/57)
138
+ - Add custom data type vcs_repo. by [@rupeshjSFDC](https://github.com/rupeshjSFDC) in [#59](https://github.com/jorgesolebur/CumulusCI/pull/59)
139
139
 
140
- **Full Changelog**: https://github.com/jorgesolebur/CumulusCI/compare/v5.0.15...v5.0.16
140
+ **Full Changelog**: https://github.com/jorgesolebur/CumulusCI/compare/v5.0.16...v5.0.17
@@ -1,4 +1,4 @@
1
- cumulusci/__about__.py,sha256=6Zfa5_jynCBYIvtkYN0Ygch4VWXnobnaeed612gFG18,23
1
+ cumulusci/__about__.py,sha256=x4NllGN1pNABBzi1vkIo-rQ2JSdgVyJUAI6uFT43BEA,23
2
2
  cumulusci/__init__.py,sha256=jdanFQ_i8vbdO7Eltsf4pOfvV4mwa_Osyc4gxWKJ8ng,764
3
3
  cumulusci/__main__.py,sha256=kgRH-n5AJrH_daCK_EJwH7azAUxdXEmpi-r-dPGMR6Y,43
4
4
  cumulusci/conftest.py,sha256=AIL98BDwNAQtdo8YFmLKwav0tmrQ5dpbw1cX2FyGouQ,5108
@@ -611,8 +611,8 @@ cumulusci/tasks/tests/test_pushfails.py,sha256=9JG9D0iD4dR-1fKheaRN7BEy3lzzuOKeR
611
611
  cumulusci/tasks/tests/test_salesforce.py,sha256=yCGtuHapxyAEmXQhuF2g2fh2naknTu7Md4OfEJQvGAA,2594
612
612
  cumulusci/tasks/tests/test_sfdx.py,sha256=oUbHo28d796m5RuskXMLitJw2rCLjjXIfxggzr4gsso,3545
613
613
  cumulusci/tasks/tests/test_util.py,sha256=D1T0QnvPTS0PHeZWo2xiVgE1jVTYcLzGTGHwEIoVmxk,7296
614
- cumulusci/tasks/utility/env_management.py,sha256=RIxciQHPVMnJjwNvYkeq30QrMISagF4qx2zSRiXjExQ,5382
615
- cumulusci/tasks/utility/tests/test_env_management.py,sha256=e0cVAohNzpDUPDvS5LrIcd2Cqv0pkQ_KYvjX6qsREj8,8155
614
+ cumulusci/tasks/utility/env_management.py,sha256=nJyv7KFtaBaAUK_40h-FpyfHTd7xSfEFkm9cj-tOhqc,6715
615
+ cumulusci/tasks/utility/tests/test_env_management.py,sha256=fw34meWGOe1YYZO449MMCi2O7BgSaOA_I_wScrIr1Uk,8702
616
616
  cumulusci/tasks/vcs/__init__.py,sha256=ZzpMZnhooXZ6r_ywBVTS3UNw9uMcXW6h33LylRqTDK0,700
617
617
  cumulusci/tasks/vcs/commit_status.py,sha256=hgPUVHeQyIfMsCuwrw2RI-ufnbjdRARc6HI3BEgdcxI,2332
618
618
  cumulusci/tasks/vcs/create_commit_status.py,sha256=kr_OFM3J32jxusS1og-K91Kl1F_Nr7SlevRsJKBhifs,1565
@@ -738,9 +738,9 @@ cumulusci/vcs/tests/dummy_service.py,sha256=RltOUpMIhSDNrfxk0LhLqlH4ppC0sK6NC2cO
738
738
  cumulusci/vcs/tests/test_vcs_base.py,sha256=9mp6uZ3lTxY4onjUNCucp9N9aB3UylKS7_2Zu_hdAZw,24331
739
739
  cumulusci/vcs/tests/test_vcs_bootstrap.py,sha256=N0NA48-rGNIIjY3Z7PtVnNwHObSlEGDk2K55TQGI8g4,27954
740
740
  cumulusci/vcs/utils/__init__.py,sha256=py4fEcHM7Vd0M0XWznOlywxaeCtG3nEVGmELmEKVGU8,869
741
- cumulusci_plus-5.0.16.dist-info/METADATA,sha256=1w8L_cNeKkI7tHu_r8PY7nltM-adAck3ZpmjDqihHCk,5773
742
- cumulusci_plus-5.0.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
743
- cumulusci_plus-5.0.16.dist-info/entry_points.txt,sha256=nTtu04b9iLXhzADcTrb5PwmdXE6e2MTUAMh9OK6Z2pg,80
744
- cumulusci_plus-5.0.16.dist-info/licenses/AUTHORS.rst,sha256=PvewjKImdKPhhJ6xR2EEZ4T7GbpY2ZeAeyWm2aLtiMQ,676
745
- cumulusci_plus-5.0.16.dist-info/licenses/LICENSE,sha256=NFsF_s7RVXk2dU6tmRAN8wF45pnD98VZ5IwqOsyBcaU,1499
746
- cumulusci_plus-5.0.16.dist-info/RECORD,,
741
+ cumulusci_plus-5.0.17.dist-info/METADATA,sha256=hO8FAqzbbv4M0ugIDh2QHRGmg7WArDbaCBGrPgW4Vto,5751
742
+ cumulusci_plus-5.0.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
743
+ cumulusci_plus-5.0.17.dist-info/entry_points.txt,sha256=nTtu04b9iLXhzADcTrb5PwmdXE6e2MTUAMh9OK6Z2pg,80
744
+ cumulusci_plus-5.0.17.dist-info/licenses/AUTHORS.rst,sha256=PvewjKImdKPhhJ6xR2EEZ4T7GbpY2ZeAeyWm2aLtiMQ,676
745
+ cumulusci_plus-5.0.17.dist-info/licenses/LICENSE,sha256=NFsF_s7RVXk2dU6tmRAN8wF45pnD98VZ5IwqOsyBcaU,1499
746
+ cumulusci_plus-5.0.17.dist-info/RECORD,,