nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: relekang/python-semantic-release
Pull request #292 (2020-12-14 18:43:40)

fix(changelog): use "issues" link vs "pull"
While, e.g., https://github.com/owner/repos/pull/123 will work, https://github.com/owner/repos/issues/123 should be safer / more consistent, and should avoid a failure if someone adds an issue link at the end of a PR that is merged via rebase merge or merge commit.


Patch:
diff --git a/semantic_release/changelog/changelog.py b/semantic_release/changelog/changelog.py
index 9f9bcc1..33c093f 100644
--- a/semantic_release/changelog/changelog.py
+++ b/semantic_release/changelog/changelog.py
@@ -18,7 +18,7 @@ def add_pr_link(owner: str, repo_name: str, message: str) -> str:
         url = (
             f"https://gitlab.com/{owner}/{repo_name}/-/merge_requests/{pr_number}"
             if config.get("hvcs") == "gitlab"
-            else f"https://github.com/{owner}/{repo_name}/pull/{pr_number}"
+            else f"https://github.com/{owner}/{repo_name}/issues/{pr_number}"
         )
 
         return re.sub(pr_pattern, f" ([#{pr_number}]({url}))", message)


Test patch:
diff --git a/tests/test_changelog.py b/tests/test_changelog.py
index ababce7..75e3eb0 100644
--- a/tests/test_changelog.py
+++ b/tests/test_changelog.py
@@ -38,7 +38,7 @@ def test_markdown_changelog():
         "* Add super-feature ([`134`](https://github.com/owner/repo_name/commit/134))\n"
         "\n"
         "### Fix\n"
-        "* Fix bug in super-feature ([#15](https://github.com/owner/repo_name/pull/15))"
+        "* Fix bug in super-feature ([#15](https://github.com/owner/repo_name/issues/15))"
         " ([`234`](https://github.com/owner/repo_name/"
         "commit/234))\n"
         "\n"
@@ -47,7 +47,7 @@ def test_markdown_changelog():
         " ([`21`](https://github.com/owner/repo_name/commit/21))\n"
         "\n"
         "### Documentation\n"
-        "* Document super-feature ([#189](https://github.com/owner/repo_name/pull/189))"
+        "* Document super-feature ([#189](https://github.com/owner/repo_name/issues/189))"
         " ([`0`](https://github.com/owner/repo_name/commit/0))"
     )
 
@@ -100,7 +100,7 @@ def test_changelog_table():
         "| --- | --- |\n"
         "| Feature | commit1 ([`sha1`](https://github.com/owner/repo_name/commit/sha1))"
         "<br>commit2 ([`sha2`](https://github.com/owner/repo_name/commit/sha2)) |\n"
-        "| Fix | commit3 ([#123](https://github.com/owner/repo_name/pull/123))"
+        "| Fix | commit3 ([#123](https://github.com/owner/repo_name/issues/123))"
         " ([`sha3`](https://github.com/owner/repo_name/commit/sha3)) |\n"
     )
 
@@ -151,7 +151,7 @@ def test_get_changelog_sections():
         (
             "test (#123)",
             "github",
-            "test ([#123](https://github.com/owner/name/pull/123))",
+            "test ([#123](https://github.com/owner/name/issues/123))",
         ),
         ("test without commit", "github", "test without commit"),
         ("test (#123) in middle", "github", "test (#123) in middle"),
Repository: relekang/python-semantic-release
Pull request #298 (2020-12-20 17:23:36)

fix(history): coerce version to string
The changes in #297 mistakenly omitted coercing the return value to a
string. This resulted in errors like:
`can only concatenate str (not "VersionInfo") to str`

Add test case asserting it's type `str`


Patch:
diff --git a/semantic_release/history/__init__.py b/semantic_release/history/__init__.py
index bff8547..532955b 100644
--- a/semantic_release/history/__init__.py
+++ b/semantic_release/history/__init__.py
@@ -175,7 +175,7 @@ def get_new_version(current_version: str, level_bump: str) -> str:
     if not level_bump:
         logger.debug("No bump requested, returning input version")
         return current_version
-    return semver.VersionInfo.parse(current_version).next_version(part=level_bump)
+    return str(semver.VersionInfo.parse(current_version).next_version(part=level_bump))
 
 
 @LoggedFunction(logger)


Test patch:
diff --git a/tests/history/test_version.py b/tests/history/test_version.py
index 13ed065..c5804b6 100644
--- a/tests/history/test_version.py
+++ b/tests/history/test_version.py
@@ -72,6 +72,7 @@ class TestGetNewVersion:
         assert get_new_version("10.1.0", "major") == "11.0.0"
 
     def test_minor_bump(self):
+        assert type(get_new_version("0.0.0", "minor")) is str
         assert get_new_version("0.0.0", "minor") == "0.1.0"
         assert get_new_version("1.2.0", "minor") == "1.3.0"
         assert get_new_version("1.2.1", "minor") == "1.3.0"
Repository: relekang/python-semantic-release
Pull request #322 (2021-02-11 17:09:56)

feat(checks): Add support for jenkins ci
Includes a ci check handler to verify jenkins.
Unlike other ci systems jenkins doesn't generally prefix things with
`JENKINS` or simply inject `JENKINS=true` Really the only thing that is
immediately identifiable is `JENKINS_URL`


Patch:
diff --git a/semantic_release/ci_checks.py b/semantic_release/ci_checks.py
index 6004559..5ae5025 100644
--- a/semantic_release/ci_checks.py
+++ b/semantic_release/ci_checks.py
@@ -100,6 +100,21 @@ def bitbucket(branch: str):
     assert not os.environ.get("BITBUCKET_PR_ID")
 
 
+@checker
+def jenkins(branch: str):
+    """
+    Performs necessary checks to ensure that the jenkins build is one
+    that should create releases.
+
+    :param branch: The branch the environment should be running against.
+    """
+
+    branch_name = os.environ.get("BRANCH_NAME") or os.environ.get("GIT_BRANCH")
+    assert os.environ.get('JENKINS_URL') is not None
+    assert branch_name == branch
+    assert not os.environ.get("CHANGE_ID") # pull request id
+
+
 def check(branch: str = "master"):
     """
     Detects the current CI environment, if any, and performs necessary
@@ -117,5 +132,7 @@ def check(branch: str = "master"):
         circle(branch)
     elif os.environ.get("GITLAB_CI") == "true":
         gitlab(branch)
+    elif os.environ.get('JENKINS_URL') is not None:
+        jenkins(branch)
     elif "BITBUCKET_BUILD_NUMBER" in os.environ:
         bitbucket(branch)


Test patch:
diff --git a/tests/ci_checks/test_jenkins.py b/tests/ci_checks/test_jenkins.py
new file mode 100644
index 0000000..be18da6
--- /dev/null
+++ b/tests/ci_checks/test_jenkins.py
@@ -0,0 +1,33 @@
+import pytest
+
+from semantic_release import ci_checks
+from semantic_release.errors import CiVerificationError
+
+def test_jenkins_should_pass_if_url_set_branch_master_no_pr(monkeypatch):
+    monkeypatch.setenv("JENKINS_URL", "http://custom.jenkins.int.com")
+    monkeypatch.setenv("BRANCH_NAME", "master")
+
+    assert ci_checks.jenkins("master")
+
+
+def test_jenkins_should_pass_if_url_set_if_branch_correct_no_pr(monkeypatch):
+    monkeypatch.setenv("JENKINS_URL", "http://custom.jenkins.int.com")
+    monkeypatch.setenv("GIT_BRANCH", "foo-bar")
+
+    assert ci_checks.jenkins("foo-bar")
+
+
+def test_jenkins_should_raise_ci_verification_error_no_url(monkeypatch):
+    monkeypatch.setenv("BRANCH_NAME", "foo-bar")
+
+    with pytest.raises(CiVerificationError):
+        assert ci_checks.jenkins("foo-bar")
+
+
+def test_jenkins_should_raise_ci_verification_error_for_pr(monkeypatch):
+    monkeypatch.setenv("JENKINS_URL", "http://custom.jenkins.int.com")
+    monkeypatch.setenv("BRANCH_NAME", "foo-bar")
+    monkeypatch.setenv("CHANGE_ID", "1")
+
+    with pytest.raises(CiVerificationError):
+        assert ci_checks.jenkins("foo-bar")
Repository: relekang/python-semantic-release
Pull request #448 (2022-05-27 15:51:05)

fix: Wrong current release version captured when patch has more than one digit
Version in init file: 0.0.24-beta.0
Detected current release version: 0.0.24
Detected current version: 0.0.2
Generated new version: 0.0.3

Tested the current regex pattern in isolation against the above version and see that match[1] is stripping the 4 in the patch version


Logs:

debug: Parsing current version: path=PosixPath('src/analytics_calc/init.py') pattern='version *[:=] *["\'](https://github.com/relekang/python-semantic-release/pull/%5Cd+%5C.%5Cd+%5C.%5Cd+(-beta%5C.%5Cd+)?)["\']' num_matches=1
debug: Regex matched version: 0.0.24
debug: get_current_version_by_config_file -> 0.0.24
debug: get_current_release_version_by_commits()
debug: Checking commit 19569b7cf15c3d21c7ed45dc335a386aed4d997e
debug: Checking commit 32ae4df6ee88c31e145f5109aa89c782c1c4795c
debug: Checking commit ccee325f58b449cdce1e623313efe7e1bbe6657d
debug: Checking commit 9a951310467c011f7050efead12059a5ce8537bc
debug: Checking commit c22ae08de4193e9c450d3d24fd07722d1a10fe6f
debug: Checking commit f453ba3f1e76e6d62c5a49ddc15f475401d8d66d
debug: Version matches regex 0.0.24-beta.0
debug:
debug: Automatically generated by python-semantic-release
debug: get_current_release_version_by_commits -> 0.0.2
Current version: 0.0.24, Current release version: 0.0.2
debug: evaluate_version_bump('0.0.24', 'patch')
debug: evaluate_version_bump -> patch
debug: get_new_version('0.0.24', '0.0.2', 'patch', True)

thomas-gallop: @jacksbox Since you have the most context here can you take a look?

Patch:
diff --git a/semantic_release/history/__init__.py b/semantic_release/history/__init__.py
index c418253..3ad7454 100644
--- a/semantic_release/history/__init__.py
+++ b/semantic_release/history/__init__.py
@@ -27,7 +27,7 @@ logger = logging.getLogger(__name__)
 
 prerelease_pattern = f"-{config.get('prerelease_tag')}\.\d+"
 version_pattern = f"(\d+\.\d+\.\d+({prerelease_pattern})?)"
-release_version_pattern = f"(\d+\.\d+\.\d+(?!{prerelease_pattern}))"
+release_version_pattern = f"(\d+\.\d+\.\d+(?!.*{prerelease_pattern}))"
 
 release_version_regex = rf"{release_version_pattern}"
 version_regex = rf"{version_pattern}"


Test patch:
diff --git a/tests/history/test_version.py b/tests/history/test_version.py
index 2250cf2..f2085bb 100644
--- a/tests/history/test_version.py
+++ b/tests/history/test_version.py
@@ -143,6 +143,13 @@ class TestGetCurrentReleaseVersionByCommits:
     def test_should_return_correct_version_from_prerelease(self):
         assert get_current_release_version_by_commits() == "0.9.0"
 
+    @mock.patch(
+        "semantic_release.history.get_commit_log",
+        lambda: [("211", "0.0.24-beta.10"), ("13", "0.0.23"), ("14", "0.0.21-beta.0"), ("15", "0.0.19")],
+    )
+    def test_should_return_correct_version_from_large_prerelease(self):
+        assert get_current_release_version_by_commits() == "0.0.23"
+
     @mock.patch(
         "semantic_release.history.get_commit_log",
         lambda: [("211", "7.28.0"), ("13", "7.27.0")],