nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: theskumar/python-dotenv
Pull request #60 (2017-08-08 11:44:15)

Added support for special characters
Without this changes the new test that I added fail. So for example, you have in your `.env` password with special characters:

```
PASSWORD="}=&~{,(\5%{&;"
```

But using package it return: `}=&~{,(%{&;` (Missing `\5`)

coveralls: 
[![Coverage Status](https://coveralls.io/builds/12740779/badge)](https://coveralls.io/builds/12740779)

Coverage remained the same at 82.418% when pulling **fa66e0bbec3e7119eebb634114c1d39bb8d61bca on pjona:special_characters** into **77dc37d0c1f7786a45c5e2971ef7794b70e913e9 on theskumar:master**.


Patch:
diff --git a/dotenv/cli.py b/dotenv/cli.py
index 125a0a8..bd9bd7a 100644
--- a/dotenv/cli.py
+++ b/dotenv/cli.py
@@ -49,7 +49,7 @@ def set(ctx, key, value):
 @click.pass_context
 @click.argument('key', required=True)
 def get(ctx, key):
-    '''Retrive the value for the given key.'''
+    '''Retrieve the value for the given key.'''
     file = ctx.obj['FILE']
     stored_value = get_key(file, key)
     if stored_value:
diff --git a/dotenv/main.py b/dotenv/main.py
index ceac3fa..de1eb6f 100644
--- a/dotenv/main.py
+++ b/dotenv/main.py
@@ -100,7 +100,7 @@ def parse_dotenv(dotenv_path):
             k, v = line.split('=', 1)
 
             # Remove any leading and trailing spaces in key, value
-            k, v = k.strip(), v.strip()
+            k, v = k.strip(), v.strip().encode('unicode-escape').decode('ascii')
 
             if len(v) > 0:
                 quoted = v[0] == v[len(v) - 1] in ['"', "'"]
@@ -114,7 +114,7 @@ def parse_dotenv(dotenv_path):
 def resolve_nested_variables(values):
     def _replacement(name):
         """
-        get appropiate value for a variable name.
+        get appropriate value for a variable name.
         first search in environ, if not found,
         then look into the dotenv variables
         """


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 449b54a..60c4ebf 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -58,6 +58,18 @@ def test_value_with_quotes():
     sh.rm(dotenv_path)
 
 
+def test_value_with_special_characters():
+    with open(dotenv_path, 'w') as f:
+        f.write(r'TEST="}=&~{,(\5%{&;"')
+    assert dotenv.get_key(dotenv_path, 'TEST') == r'}=&~{,(\5%{&;'
+    sh.rm(dotenv_path)
+
+    with open(dotenv_path, 'w') as f:
+        f.write(r"TEST='}=&~{,(\5%{&;'")
+    assert dotenv.get_key(dotenv_path, 'TEST') == r'}=&~{,(\5%{&;'
+    sh.rm(dotenv_path)
+
+
 def test_unset():
     sh.touch(dotenv_path)
     success, key_to_set, value_to_set = dotenv.set_key(dotenv_path, 'HELLO', 'WORLD')
Repository: theskumar/python-dotenv
Pull request #109 (2018-04-27 16:37:19)

Fix to enable loading from current directory
This is a fix for #108, which is due I believe to the fact that `find_dotenv` does not go back far enough in the call stack to find the calling module, which causes its path searching starting point to be itself (i.e. `main.py`).

@theskumar, @RazerM 

RazerM: There should probably be a test added that fails with current master but is fixed by this change.
cjauvin: @RazerM You're right, I added such a test.
cjauvin: Oops I'm sorry, I made a mistake, I'm investigating it.
pvmm: This is an important correction. It would be nice to have this merged back in.
cjauvin: @pvmm I thought so too, but this PR has received zero attention from the maintainers since I opened it almost two months ago.
fourjr: Bumping this issue as its pretty important 

Patch:
diff --git a/dotenv/main.py b/dotenv/main.py
index cdb5d9d..252a2dd 100644
--- a/dotenv/main.py
+++ b/dotenv/main.py
@@ -232,7 +232,11 @@ def find_dotenv(filename='.env', raise_error_if_not_found=False, usecwd=False):
         path = os.getcwd()
     else:
         # will work for .py files
-        frame_filename = sys._getframe().f_back.f_code.co_filename
+        frame = sys._getframe()
+        # find first frame that is outside of this file
+        while frame.f_code.co_filename == __file__:
+            frame = frame.f_back
+        frame_filename = frame.f_code.co_filename
         path = os.path.dirname(os.path.abspath(frame_filename))
 
     for dirname in _walk_to_root(path):


Test patch:
diff --git a/tests/test_core.py b/tests/test_core.py
index a7fb347..1547e24 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1,4 +1,4 @@
-# -*- coding: utf8 -*-
+# -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
 import os
@@ -107,6 +107,19 @@ def test_load_dotenv_override(cli):
         sh.rm(dotenv_path)
 
 
+def test_load_dotenv_in_current_dir():
+    # make sure were are here!
+    os.chdir(os.path.dirname(os.path.realpath(__file__)))
+    dotenv_path = '.env'
+    with open(dotenv_path, 'w') as f:
+        f.write("TOTO=bla\n")
+    assert 'TOTO' not in os.environ
+    success = load_dotenv(verbose=True)
+    assert success
+    assert os.environ['TOTO'] == 'bla'
+    sh.rm(dotenv_path)
+
+
 def test_ipython():
     tmpdir = os.path.realpath(tempfile.mkdtemp())
     os.chdir(tmpdir)
Repository: theskumar/python-dotenv
Pull request #118 (2018-07-03 15:47:59)

Fix typo in README

coveralls: 
[![Coverage Status](https://coveralls.io/builds/17813864/badge)](https://coveralls.io/builds/17813864)

Coverage remained the same at 90.875% when pulling **1a30b4e4e59092d57e9c879c655142cf5e0fbea1 on jackscotti:patch-1** into **b20d818c9296817352f5d0d7cb7b8acd90a2548d on theskumar:master**.


Patch:
diff --git a/README.md b/README.md
index 1ec2c03..67fe928 100644
--- a/README.md
+++ b/README.md
@@ -285,7 +285,7 @@ Changelog
 -----
 
 -   Add tests for docs ([@Flimm])
--   Make 'cli' support optional. Use `pip install python-dotnev[cli]`. ([@theskumar])
+-   Make 'cli' support optional. Use `pip install python-dotenv[cli]`. ([@theskumar])
 
 0.8.0
 -----
diff --git a/dotenv/main.py b/dotenv/main.py
index cdb5d9d..252a2dd 100644
--- a/dotenv/main.py
+++ b/dotenv/main.py
@@ -232,7 +232,11 @@ def find_dotenv(filename='.env', raise_error_if_not_found=False, usecwd=False):
         path = os.getcwd()
     else:
         # will work for .py files
-        frame_filename = sys._getframe().f_back.f_code.co_filename
+        frame = sys._getframe()
+        # find first frame that is outside of this file
+        while frame.f_code.co_filename == __file__:
+            frame = frame.f_back
+        frame_filename = frame.f_code.co_filename
         path = os.path.dirname(os.path.abspath(frame_filename))
 
     for dirname in _walk_to_root(path):


Test patch:
diff --git a/tests/test_core.py b/tests/test_core.py
index a7fb347..1547e24 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1,4 +1,4 @@
-# -*- coding: utf8 -*-
+# -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
 import os
@@ -107,6 +107,19 @@ def test_load_dotenv_override(cli):
         sh.rm(dotenv_path)
 
 
+def test_load_dotenv_in_current_dir():
+    # make sure were are here!
+    os.chdir(os.path.dirname(os.path.realpath(__file__)))
+    dotenv_path = '.env'
+    with open(dotenv_path, 'w') as f:
+        f.write("TOTO=bla\n")
+    assert 'TOTO' not in os.environ
+    success = load_dotenv(verbose=True)
+    assert success
+    assert os.environ['TOTO'] == 'bla'
+    sh.rm(dotenv_path)
+
+
 def test_ipython():
     tmpdir = os.path.realpath(tempfile.mkdtemp())
     os.chdir(tmpdir)
Repository: theskumar/python-dotenv
Pull request #125 (2018-08-05 15:03:14)

Bugfix: parse_line incorrectly strips "export " prefix
`parse_line` currently implements the stripping of the `"export "` prefix incorrectly, such that any variable name prefix consisting of the characters ` eoprtx` will get stripped too.

This means that for example `export port_number = 8000` will get parsed as `_number = 8000`.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/18332623/badge)](https://coveralls.io/builds/18332623)

Coverage decreased (-0.5%) to 91.822% when pulling **cfb15b2d466ce9d27fbfea7c8c50b28d9f51c041 on pjdelport:fix-parse-line-export** into **d143c897d61ba75cf49454b8174aaaf6c5580272 on theskumar:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/18332623/badge)](https://coveralls.io/builds/18332623)

Coverage decreased (-0.5%) to 91.822% when pulling **cfb15b2d466ce9d27fbfea7c8c50b28d9f51c041 on pjdelport:fix-parse-line-export** into **d143c897d61ba75cf49454b8174aaaf6c5580272 on theskumar:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/18332623/badge)](https://coveralls.io/builds/18332623)

Coverage decreased (-0.5%) to 91.822% when pulling **cfb15b2d466ce9d27fbfea7c8c50b28d9f51c041 on pjdelport:fix-parse-line-export** into **d143c897d61ba75cf49454b8174aaaf6c5580272 on theskumar:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/18332623/badge)](https://coveralls.io/builds/18332623)

Coverage decreased (-0.5%) to 91.822% when pulling **cfb15b2d466ce9d27fbfea7c8c50b28d9f51c041 on pjdelport:fix-parse-line-export** into **d143c897d61ba75cf49454b8174aaaf6c5580272 on theskumar:master**.

theskumar: Thanks, I didn't knew about such behaviour of `lstrip`. I'll look into the coverage report, you can ignore it for now. :)

Patch:
diff --git a/dotenv/main.py b/dotenv/main.py
index 252a2dd..4bf7294 100644
--- a/dotenv/main.py
+++ b/dotenv/main.py
@@ -31,7 +31,7 @@ def parse_line(line):
     k, v = line.split('=', 1)
 
     if k.startswith('export '):
-        k = k.lstrip('export ')
+        (_, _, k) = k.partition('export ')
 
     # Remove any leading and trailing spaces in key, value
     k, v = k.strip(), v.strip()


Test patch:
diff --git a/tests/test_core.py b/tests/test_core.py
index 1547e24..4c03f8e 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -24,6 +24,8 @@ from IPython.terminal.embed import InteractiveShellEmbed
     ("a=b space ", ('a', 'b space')),
     ("a='b space '", ('a', 'b space ')),
     ('a="b space "', ('a', 'b space ')),
+    ("export export_spam=1", ("export_spam", "1")),
+    ("export port=8000", ("port", "8000")),
 ])
 def test_parse_line(test_input, expected):
     assert parse_line(test_input) == expected
Repository: SFDO-Tooling/CumulusCI
Pull request #3662 (2023-09-21 15:22:17)

Added Namespace in org info

jain-naman-sf: Hi @davidmreed. This PR solves this [issue](https://github.com/SFDO-Tooling/CumulusCI/issues/3512).
Please review this once and suggest any changes if required.
davidmreed: Closes #3512. (Note: @jain-naman-sf, `Closes` and `Fixes` are keywords that GitHub understands, so it will automatically close the issue when your PR merges!)

Patch:
diff --git a/cumulusci/cli/org.py b/cumulusci/cli/org.py
index 4dc5ed3e6..c8ee718e6 100644
--- a/cumulusci/cli/org.py
+++ b/cumulusci/cli/org.py
@@ -330,6 +330,7 @@ def org_info(runtime, org_name, print_json):
             "instance_url",
             "instance_name",
             "is_sandbox",
+            "namespace",
             "namespaced",
             "org_id",
             "org_type",


Test patch:
diff --git a/cumulusci/cli/tests/test_org.py b/cumulusci/cli/tests/test_org.py
index 01692e22a..007e82249 100644
--- a/cumulusci/cli/tests/test_org.py
+++ b/cumulusci/cli/tests/test_org.py
@@ -540,6 +540,7 @@ class TestOrgCommands:
             "default": True,
             "password": None,
             "connected_app": "built-in",
+            "namespace": "test",
         }
         org_config.expires = date.today()
         org_config.latest_api_version = "42.0"
@@ -557,6 +558,7 @@ class TestOrgCommands:
                     ["\x1b[1mconnected_app\x1b[0m", "built-in"],
                     ["\x1b[1mdays\x1b[0m", "1"],
                     ["\x1b[1mdefault\x1b[0m", "True"],
+                    ["\x1b[1mnamespace\x1b[0m", "test"],
                     ["\x1b[1mpassword\x1b[0m", "None"],
                 ],
             )
Repository: SFDO-Tooling/CumulusCI
Pull request #3679 (2023-10-13 07:04:07)

Error message when git remote URL throws exception if no origin remote
Fails to give the error message when run any task involving git if the URL doesn't contain the origin remote.

This is because in the project config URL is set to None due to this`url = self.git_config_remote_origin_url()` 
and when the below function is called. Parse_repo_url is called with None as argument.

`def get_github_api_for_repo(keychain, repo_url, session=None) -> GitHub:
    owner, repo_name, host = parse_repo_url(repo_url)`

Work item: [link](https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00001M62egYAB/view)


lakshmi2506: Hi @jkasturi-sf 

I have added the clear error for the parse_url when the url passed doesn't have remote set as origin

please review the code
Thank you
lakshmi2506: Hi @jstvz 

Requested changes are made. Please go through the changes.
Thank you

Patch:
diff --git a/cumulusci/utils/git.py b/cumulusci/utils/git.py
index 2e822bf7d..a540e22d3 100644
--- a/cumulusci/utils/git.py
+++ b/cumulusci/utils/git.py
@@ -2,6 +2,10 @@ import pathlib
 import re
 from typing import Any, Optional, Tuple
 
+EMPTY_URL_MESSAGE = """
+The provided URL is empty or no URL under git remote "origin".
+"""
+
 
 def git_path(repo_root: str, tail: Any = None) -> Optional[pathlib.Path]:
     """Returns a Path to the .git directory in repo_root
@@ -71,6 +75,9 @@ def parse_repo_url(url: str) -> Tuple[str, str, str]:
     Tuple: (str, str, str)
         Returns (owner, name, host)
     """
+    if not url:
+        raise ValueError(EMPTY_URL_MESSAGE)
+
     url_parts = re.split("/|@|:", url.rstrip("/"))
 
     name = url_parts[-1]


Test patch:
diff --git a/cumulusci/utils/tests/test_git.py b/cumulusci/utils/tests/test_git.py
index f7cf56eb5..7496486a1 100644
--- a/cumulusci/utils/tests/test_git.py
+++ b/cumulusci/utils/tests/test_git.py
@@ -1,6 +1,7 @@
 import pytest
 
 from cumulusci.utils.git import (
+    EMPTY_URL_MESSAGE,
     construct_release_branch_name,
     get_release_identifier,
     is_release_branch,
@@ -69,3 +70,9 @@ def test_construct_release_branch_name():
 def test_parse_repo_url(repo_uri, owner, repo_name, host):
     assert parse_repo_url(repo_uri) == (owner, repo_name, host)
     assert split_repo_url(repo_uri) == (owner, repo_name)
+
+
+@pytest.mark.parametrize("URL", [None, ""])
+def test_empty_url(URL):
+    with pytest.raises(ValueError, match=EMPTY_URL_MESSAGE):
+        parse_repo_url(URL)
Repository: SFDO-Tooling/CumulusCI
Pull request #3736 (2024-01-29 08:22:07)

updated return_values for task get_assigned_permission_sets
[W-14910021](https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00001j2AULYA2/view)

Retrieved list of assigned permission sets are assigned for the `task.return_values` to ensure the preflight check conditions are checked properly


Patch:
diff --git a/cumulusci/tasks/preflight/permsets.py b/cumulusci/tasks/preflight/permsets.py
index c02ff93f9..fe7adf39d 100644
--- a/cumulusci/tasks/preflight/permsets.py
+++ b/cumulusci/tasks/preflight/permsets.py
@@ -5,16 +5,16 @@ class GetPermissionSetAssignments(BaseSalesforceApiTask):
     def _run_task(self):
         query = f"SELECT PermissionSet.Name,PermissionSetGroupId FROM PermissionSetAssignment WHERE AssigneeId = '{self.org_config.user_id}'"
 
-        self.permsets = []
+        self.return_values = []
         for result in self.sf.query_all(query)["records"]:
-            if result["PermissionSet"]["Name"] not in self.permsets:
-                self.permsets.append(result["PermissionSet"]["Name"])
+            if result["PermissionSet"]["Name"] not in self.return_values:
+                self.return_values.append(result["PermissionSet"]["Name"])
 
             if result["PermissionSetGroupId"] is not None:
                 psg_query = f"SELECT PermissionSet.Name from PermissionSetGroupComponent where PermissionSetGroupId = '{result['PermissionSetGroupId']}'"
                 for psg_result in self.sf.query_all(psg_query)["records"]:
-                    if psg_result["PermissionSet"]["Name"] not in self.permsets:
-                        self.permsets.append(psg_result["PermissionSet"]["Name"])
+                    if psg_result["PermissionSet"]["Name"] not in self.return_values:
+                        self.return_values.append(psg_result["PermissionSet"]["Name"])
 
-        permsets_str = "\n".join(self.permsets)
+        permsets_str = "\n".join(self.return_values)
         self.logger.info(f"Found permission sets assigned:\n{permsets_str}")


Test patch:
diff --git a/cumulusci/tasks/preflight/tests/test_permset_preflights.py b/cumulusci/tasks/preflight/tests/test_permset_preflights.py
index eded8f95f..096378093 100644
--- a/cumulusci/tasks/preflight/tests/test_permset_preflights.py
+++ b/cumulusci/tasks/preflight/tests/test_permset_preflights.py
@@ -43,9 +43,8 @@ class TestPermsetPreflights:
             },
         ]
         task()
-
         task._init_api.return_value.query_all.assert_called()
-        assert task.permsets == [
+        assert task.return_values == [
             "DocumentChecklist",
             "EinsteinAnalyticsPlusAdmin",
             "CustomerExperienceAnalyticsAdmin",
Repository: SFDO-Tooling/CumulusCI
Pull request #3795 (2024-05-29 11:33:18)

Updated the PermissionSetLicenseKey to DeveloperName
The PermissionSetLicenseKey have the naming format as `SalesforceCPQ.CPQStandardPerm` and the actual developer name is `SalesforceCPQ_CPQStandardPerm` and to avoid errors .

Replaced with the developername


Patch:
diff --git a/cumulusci/tasks/preflight/licenses.py b/cumulusci/tasks/preflight/licenses.py
index cc40ed159..1c059dbee 100644
--- a/cumulusci/tasks/preflight/licenses.py
+++ b/cumulusci/tasks/preflight/licenses.py
@@ -16,9 +16,9 @@ class GetAvailableLicenses(BaseSalesforceApiTask):
 class GetAvailablePermissionSetLicenses(BaseSalesforceApiTask):
     def _run_task(self):
         self.return_values = [
-            result["PermissionSetLicenseKey"]
+            result["DeveloperName"]
             for result in self.sf.query(
-                "SELECT PermissionSetLicenseKey FROM PermissionSetLicense"
+                "SELECT DeveloperName FROM PermissionSetLicense"
             )["records"]
         ]
         licenses = "\n".join(self.return_values)


Test patch:
diff --git a/cumulusci/tasks/preflight/tests/test_licenses.py b/cumulusci/tasks/preflight/tests/test_licenses.py
index f2cf117ad..6df7daff5 100644
--- a/cumulusci/tasks/preflight/tests/test_licenses.py
+++ b/cumulusci/tasks/preflight/tests/test_licenses.py
@@ -34,14 +34,14 @@ class TestLicensePreflights:
         task._init_api.return_value.query.return_value = {
             "totalSize": 2,
             "records": [
-                {"PermissionSetLicenseKey": "TEST1"},
-                {"PermissionSetLicenseKey": "TEST2"},
+                {"DeveloperName": "TEST1"},
+                {"DeveloperName": "TEST2"},
             ],
         }
         task()
 
         task._init_api.return_value.query.assert_called_once_with(
-            "SELECT PermissionSetLicenseKey FROM PermissionSetLicense"
+            "SELECT DeveloperName FROM PermissionSetLicense"
         )
         assert task.return_values == ["TEST1", "TEST2"]