nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: SFDO-Tooling/CumulusCI
Pull request #3037 (2022-01-18 22:35:30)

Raise UsageError if project default set outside project directory
# Critical Changes

# Changes

# Issues Closed
- `cci service default --project` presents a better error message when called outside of a project.



Patch:
diff --git a/cumulusci/cli/service.py b/cumulusci/cli/service.py
index 49e8d6e22..50bda6201 100644
--- a/cumulusci/cli/service.py
+++ b/cumulusci/cli/service.py
@@ -286,6 +286,10 @@ def service_info(runtime, service_type, service_name, plain):
 )
 @pass_runtime(require_project=False, require_keychain=True)
 def service_default(runtime, service_type, service_name, project):
+    if not runtime.project_config and project:
+        raise click.UsageError(
+            "The --project flag must be used while in a CumulusCI project directory."
+        )
     try:
         runtime.keychain.set_default_service(service_type, service_name, project)
     except ServiceNotConfigured as e:


Test patch:
diff --git a/cumulusci/cli/tests/test_service.py b/cumulusci/cli/tests/test_service.py
index 6ca6b4bbc..e8595303a 100644
--- a/cumulusci/cli/tests/test_service.py
+++ b/cumulusci/cli/tests/test_service.py
@@ -439,6 +439,21 @@ def test_service_default__project(echo):
     )
 
 
+def test_service_connect__project_default_no_project():
+    runtime = mock.Mock()
+    runtime.project_config = None
+    runtime.keychain.project_local_dir = "test"
+
+    with pytest.raises(click.UsageError):
+        run_click_command(
+            service.service_default,
+            runtime=runtime,
+            service_type="test",
+            service_name="test-alias",
+            project=True,
+        )
+
+
 @mock.patch("click.echo")
 def test_service_default__exception(echo):
     runtime = mock.Mock()
Repository: SFDO-Tooling/CumulusCI
Pull request #3044 (2022-01-20 22:45:05)

Tweak Oauth App org restriction docs
This PR tweaks the trigger for warn_oauth_restricted error handler
to reflect upstream changes (ideally they'd give us an HTTP header, but
alas). It also adds a note to the onboarding docs to make the workaround
explicit.

# Critical Changes

# Changes

# Issues Closed


github-actions[bot]: This pull request has been labeled as ready for docs review and requires review from @SFDO-Tooling/doc-writers. This workflow will fail until this pull request is labeled as 'docs reviewed'.
davisagli: github actions seems stuck. I'm going to bypass branch protection to merge this, since the builds already passed and it's not touching code.

Patch:
diff --git a/cumulusci/core/github.py b/cumulusci/core/github.py
index 17c103ef4..b6e5d0539 100644
--- a/cumulusci/core/github.py
+++ b/cumulusci/core/github.py
@@ -374,7 +374,7 @@ def warn_oauth_restricted(exc: ResponseError) -> str:
 
     is_403 = exc.response.status_code == 403
     org_restricted_oauth_warning = (
-        "organization has enabled OAuth App access restrictions"
+        "organization has enabled OAuth App access restriction"
     )
 
     if is_403 and org_restricted_oauth_warning in str(exc):
diff --git a/docs/get_started.rst b/docs/get_started.rst
index a429be5d1..ebda8dad2 100644
--- a/docs/get_started.rst
+++ b/docs/get_started.rst
@@ -187,6 +187,8 @@ to open a browser and authenticate with your GitHub account using the one-time c
 
 After you've configured the ``github`` service, it's available to *all* CumulusCI projects.
 
+.. note:: If your GitHub organization has enabled OAuth App access restrictions, CumulusCI will not be able to access organization repositories until it has been `approved by an owner <https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-user-account/managing-your-membership-in-organizations/requesting-organization-approval-for-oauth-apps>`_. You can use a personal access token instead.
+
 Alternatively, you may `create a new personal access token <https://github.com/settings/tokens/new>`_ with both **repo** and **gist** scopes specified. (Scopes appear as checkboxes when creating the personal access token in GitHub.) Copy the access token to use when configuring the GitHub service.
 
 Next, run the following command and provide your GitHub username and access token:


Test patch:
diff --git a/cumulusci/core/tests/test_github.py b/cumulusci/core/tests/test_github.py
index e4c13aa15..c756a70bb 100644
--- a/cumulusci/core/tests/test_github.py
+++ b/cumulusci/core/tests/test_github.py
@@ -497,7 +497,7 @@ class TestGithub(GithubApiTestMixin):
     def test_github_oauth_org_restricted(self):
         resp = Response()
         resp.status_code = 403
-        body = {"message": "organization has enabled OAuth App access restrictions"}
+        body = {"message": "organization has enabled OAuth App access restriction"}
         resp._content = json.dumps(body)
         exc = ForbiddenError(resp)
Repository: SFDO-Tooling/CumulusCI
Pull request #3277 (2022-07-08 16:59:55)

Fix `metadeploy_publish` error caused by supported_orgs case-sensitivity
When running metadeploy_publish, users received an error from the REST
API:
```
Error: b'{"supported_orgs":["\\"persistent\\" is not a valid choice."]}'
```

because the Plan.supported_orgs field in MDP is case-sensitive. We
switch to title case on client-side in this PR.


Patch:
diff --git a/cumulusci/tasks/metadeploy.py b/cumulusci/tasks/metadeploy.py
index 56e84015c..25914b21e 100644
--- a/cumulusci/tasks/metadeploy.py
+++ b/cumulusci/tasks/metadeploy.py
@@ -259,11 +259,11 @@ class Publish(BaseMetaDeployTask):
         corresponds `supported_orgs` field on the Plan model in MetaDeploy
         """
         if not providers or providers == ["user"]:
-            org_providers = "persistent"
+            org_providers = "Persistent"
         elif "user" in providers and "devhub" in providers:
-            org_providers = "both"
+            org_providers = "Both"
         elif providers == ["devhub"]:
-            org_providers = "scratch"
+            org_providers = "Scratch"
 
         return org_providers
 


Test patch:
diff --git a/cumulusci/tasks/tests/test_metadeploy.py b/cumulusci/tasks/tests/test_metadeploy.py
index 2b90b8012..77e1c31ca 100644
--- a/cumulusci/tasks/tests/test_metadeploy.py
+++ b/cumulusci/tasks/tests/test_metadeploy.py
@@ -271,7 +271,7 @@ class TestPublish(GithubApiTestMixin):
         task()
 
         body = json.loads(responses.calls[-2].request.body)
-        assert body["supported_orgs"] == "both"
+        assert body["supported_orgs"] == "Both"
 
         steps = body["steps"]
         self.maxDiff = None
@@ -530,9 +530,9 @@ class TestPublish(GithubApiTestMixin):
         assert steps == []
 
     providers = [
-        (["user"], "persistent"),
-        (["devhub"], "scratch"),
-        (["user", "devhub"], "both"),
+        (["user"], "Persistent"),
+        (["devhub"], "Scratch"),
+        (["user", "devhub"], "Both"),
     ]
 
     @pytest.mark.parametrize("org_providers,metadeploy_equivalent", providers)
Repository: SFDO-Tooling/CumulusCI
Pull request #3367 (2022-09-21 20:06:48)

Fix CCI --version flag


Patch:
diff --git a/cumulusci/cli/cci.py b/cumulusci/cli/cci.py
index 96603f176..adc50c49d 100644
--- a/cumulusci/cli/cci.py
+++ b/cumulusci/cli/cci.py
@@ -183,8 +183,24 @@ def display_release_notes_link(latest_version: str) -> None:
     )
 
 
+def version_info_wrapper(
+    ctx: click.Context, param: click.Parameter, value: bool
+) -> None:
+    if not value:
+        return
+    show_version_info()
+    ctx.exit()
+
+
 @click.group("main", help="")
-@click.version_option(show_version_info, message="")
+@click.option(  # based on https://click.palletsprojects.com/en/8.1.x/options/#callbacks-and-eager-options
+    "--version",
+    is_flag=True,
+    expose_value=False,
+    is_eager=True,
+    help="Show the version and exit.",
+    callback=version_info_wrapper,
+)
 def cli():
     """Top-level `click` command group."""
 


Test patch:
diff --git a/cumulusci/cli/tests/test_cci.py b/cumulusci/cli/tests/test_cci.py
index 496d32e66..1fae62beb 100644
--- a/cumulusci/cli/tests/test_cci.py
+++ b/cumulusci/cli/tests/test_cci.py
@@ -514,3 +514,28 @@ def mock_validate_debug(value):
         assert bool(self.debug_mode) == bool(value)
 
     return _run_task
+
+
+@mock.patch("cumulusci.cli.cci.tee_stdout_stderr")
+@mock.patch("cumulusci.cli.cci.get_tempfile_logger")
+@mock.patch("cumulusci.cli.cci.init_logger")
+@mock.patch("cumulusci.cli.cci.check_latest_version")
+@mock.patch("cumulusci.cli.cci.CliRuntime")
+@mock.patch("cumulusci.cli.cci.show_version_info")
+def test_dash_dash_version(
+    show_version_info,
+    CliRuntime,
+    check_latest_version,
+    init_logger,
+    get_tempfile_logger,
+    tee,
+):
+    get_tempfile_logger.return_value = mock.Mock(), "tempfile.log"
+    cci.main(["cci", "--help"])
+    assert len(show_version_info.mock_calls) == 0
+
+    cci.main(["cci", "version"])
+    assert len(show_version_info.mock_calls) == 1
+
+    cci.main(["cci", "--version"])
+    assert len(show_version_info.mock_calls) == 2