Repository: relekang/python-semantic-release (python)

Issue:
Gitlab issue references in commits can be rendered as merge-requests
## The problem

If a commit message such as:-

```
fix: Check if issue integration works (#3)
```

where `#3` links to an issue - as per https://docs.gitlab.com/ee/user/markdown.html#gitlab-specific-references - and shows as an issue link when viewed on gitlab.

This is rendered in the changelog (with added newlines) as:-

```markdown
* Check if issue integration works 
  ([#3](https://gitlab.local/fred/project/-/merge_requests/3)) 
  ([`c3f8abd`](https://gitlab.local/fred/project/-/commit/c3f8abd9acaff597e6eae67c61e218556078b8cd))
```

Which links to `merge-request 3` - which would be `!3` as a gitlab link.

## Expected behavior

The changelog render should be:-

```markdown
* Check if issue integration works 
  ([#3](https://gitlab.local/fred/project/-/issues/3)) 
  ([`c3f8abd`](https://gitlab.local/fred/project/-/commit/c3f8abd9acaff597e6eae67c61e218556078b8cd))
```

However I see that `#3` can be either a github (not gitlab) issue or PR.  Helpful!

## Additional context

The other Changelog enhancements that are in the queue might well fix this in passing...

The specific problem is in https://github.com/relekang/python-semantic-release/blob/2111d1e81d3f6210ad00289a788ede199a17ee33/semantic_release/changelog/changelog.py#L19-L23

Pull request:
fix: correct rendering of gitlab issue references
resolves #358

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f5c3290..d766b8e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
 
 <!--next-version-placeholder-->
 
+## v7.16.3 (2021-07-29)
+### Fix
+* Print right info if token is not set (#360) ([#361](https://github.com/relekang/python-semantic-release/issues/361)) ([`a275a7a`](https://github.com/relekang/python-semantic-release/commit/a275a7a17def85ff0b41d254e4ee42772cce1981))
+
 ## v7.16.2 (2021-06-25)
 ### Fix
 * Use release-api for gitlab ([`1ef5cab`](https://github.com/relekang/python-semantic-release/commit/1ef5caba2d8dd0f2647bc51ede0ef7152d8b7b8d))
diff --git a/semantic_release/__init__.py b/semantic_release/__init__.py
index a2d81f7..0cc6668 100644
--- a/semantic_release/__init__.py
+++ b/semantic_release/__init__.py
@@ -1,6 +1,6 @@
 """Semantic Release
 """
-__version__ = "7.16.2"
+__version__ = "7.16.3"
 
 
 from .errors import UnknownCommitMessageStyleError  # noqa; noqa
diff --git a/semantic_release/changelog/changelog.py b/semantic_release/changelog/changelog.py
index 2f973f4..7259537 100644
--- a/semantic_release/changelog/changelog.py
+++ b/semantic_release/changelog/changelog.py
@@ -17,7 +17,7 @@ def add_pr_link(owner: str, repo_name: str, message: str) -> str:
     if match:
         pr_number = match.group(1)
         url = (
-            f"https://{Gitlab.domain()}/{owner}/{repo_name}/-/merge_requests/{pr_number}"
+            f"https://{Gitlab.domain()}/{owner}/{repo_name}/-/issues/{pr_number}"
             if config.get("hvcs") == "gitlab"
             else f"https://{Github.domain()}/{owner}/{repo_name}/issues/{pr_number}"
         )
diff --git a/semantic_release/cli.py b/semantic_release/cli.py
index 4495dd4..e2282f0 100644
--- a/semantic_release/cli.py
+++ b/semantic_release/cli.py
@@ -318,14 +318,20 @@ def publish(**kwargs):
             logger.warning("Missing token: cannot post changelog to HVCS")
 
         # Upload to GitHub Releases
-        if upload_release and check_token():
-            logger.info("Uploading to HVCS release")
-            upload_to_release(owner, name, new_version, dist_path)
+        if upload_release:
+            if check_token():
+                logger.info("Uploading to HVCS release")
+                upload_to_release(owner, name, new_version, dist_path)
+                logger.info("Upload to HVCS is complete")
+            else:
+                logger.warning("Missing token: cannot upload to HVCS")
+
         # Remove distribution files as they are no longer needed
         if should_remove_dist():
+            logger.info("Removing distribution files")
             remove_dists(dist_path)
 
-        logger.info("New release published")
+        logger.info("Publish has finished")
 
     # else: Since version shows a message on failure, we do not need to print another.
 


Test patch:
diff --git a/tests/test_changelog.py b/tests/test_changelog.py
index 75e3eb0..5834f80 100644
--- a/tests/test_changelog.py
+++ b/tests/test_changelog.py
@@ -74,14 +74,14 @@ def test_markdown_changelog_gitlab():
             # Expected output with the default configuration
             "### Feature\n"
             "* Add non-breaking super-feature ([#1](https://gitlab.com/owner/"
-            "repo_name/-/merge_requests/1)) ([`145`](https://gitlab.com/owner/"
+            "repo_name/-/issues/1)) ([`145`](https://gitlab.com/owner/"
             "repo_name/-/commit/145))\n"
             "* Add super-feature ([`134`](https://gitlab.com/owner/repo_name/-/"
             "commit/134))\n"
             "\n"
             "### Documentation\n"
             "* Document super-feature ([#189](https://gitlab.com/owner/repo_name/"
-            "-/merge_requests/189)) ([`0`](https://gitlab.com/owner/repo_name/"
+            "-/issues/189)) ([`0`](https://gitlab.com/owner/repo_name/"
             "-/commit/0))"
         )
 
@@ -158,7 +158,7 @@ def test_get_changelog_sections():
         (
             "test (#123)",
             "gitlab",
-            "test ([#123](https://gitlab.com/owner/name/-/merge_requests/123))",
+            "test ([#123](https://gitlab.com/owner/name/-/issues/123))",
         ),
         ("test without commit", "gitlab", "test without commit"),
     ],