Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor remotes module #688

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/integration.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Integration ⚙️
description: Report a bug or request a feature about an integration (e.g GitHub/GitLab/Bitbucket)
description: Report a bug or request a feature about an integration (e.g GitHub/GitLab/Gitea/Bitbucket)
labels: ["integration"]
assignees:
- orhun
Expand Down
46 changes: 46 additions & 0 deletions .github/fixtures/test-gitea-integration/cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[remote.gitea]
owner = "ThetaDev"
repo = "git-cliff-readme-example"

[changelog]
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
## What's Changed
{%- if version %} in {{ version }}{%- endif -%}
{% for commit in commits %}
* {{ commit.message | split(pat="\n") | first | trim }}\
{% if commit.gitea.username %} by @{{ commit.gitea.username }}{%- endif -%}
{% if commit.gitea.pr_number %} in #{{ commit.gitea.pr_number }}{%- endif %}
{%- endfor -%}
{% if gitea.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
{% raw %}\n{% endraw -%}
## New Contributors
{%- endif %}\
{% for contributor in gitea.contributors | filter(attribute="is_first_time", value=true) %}
* @{{ contributor.username }} made their first contribution
{%- if contributor.pr_number %} in \
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
{%- endif %}
{%- endfor -%}
{% raw %}\n\n{% endraw -%}
"""
# remove the leading and trailing whitespace from the template
trim = true
# changelog footer
footer = """
<!-- generated by -cliff -->
"""

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = false
# filter out the commits that are not conventional
filter_unconventional = true
# process each line of a commit as an individual commit
split_commits = false
# regex for preprocessing the commit messages
commit_preprocessors = [{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" }]
# protect breaking changes from being skipped due to matching a skipping commit_parser
protect_breaking_commits = false
6 changes: 6 additions & 0 deletions .github/fixtures/test-gitea-integration/commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -e

git remote add origin https://codeberg.org/ThetaDev/git-cliff-readme-example.git
git pull origin master
git fetch --tags
15 changes: 15 additions & 0 deletions .github/fixtures/test-gitea-integration/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## What's Changed
* Initial commit by @ThetaDev
* docs(project): add README.md by @ThetaDev
* feat(parser): add ability to parse arrays by @ThetaDev
* fix(args): rename help argument due to conflict by @ThetaDev
* docs(example)!: add tested usage example by @ThetaDev
* refactor(parser): expose string functions by @ThetaDev
* chore(release): add release script by @ThetaDev
* feat(config): support multiple file formats by @ThetaDev
* feat(cache): use cache while fetching pages by @ThetaDev

## New Contributors
* @ThetaDev made their first contribution

<!-- generated by -cliff -->
3 changes: 3 additions & 0 deletions .github/workflows/test-fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
include:
- fixtures-name: new-fixture-template
- fixtures-name: test-github-integration
- fixtures-name: test-gitlab-integration
- fixtures-name: test-gitea-integration
- fixtures-name: test-bitbucket-integration
- fixtures-name: test-ignore-tags
- fixtures-name: test-topo-order
command: --latest
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rust-analyzer.cargo.features": "all"
}
32 changes: 32 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 15 additions & 20 deletions git-cliff-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "git-cliff-core"
version = "2.3.0" # managed by release.sh
version = "2.3.0" # managed by release.sh
description = "Core library of git-cliff"
authors = ["git-cliff contributors <[email protected]>"]
license = "MIT OR Apache-2.0"
Expand All @@ -17,36 +17,29 @@ default = ["repo"]
## You can turn this off if you already have the commits to put in the
## changelog and you don't need `git-cliff` to parse them.
repo = ["dep:git2", "dep:glob", "dep:indexmap"]
## Enable integration with GitHub.
## You can turn this off if you don't use GitHub and don't want
## to make network requests to the GitHub API.
github = [
remote = [
"dep:reqwest",
"dep:http-cache-reqwest",
"dep:reqwest-middleware",
"dep:tokio",
"dep:futures",
]
## Enable integration with GitHub.
## You can turn this off if you don't use GitHub and don't want
## to make network requests to the GitHub API.
github = ["remote"]
## Enable integration with GitLab.
## You can turn this off if you don't use GitLab and don't want
## to make network requests to the GitLab API.
gitlab = [
"dep:reqwest",
"dep:http-cache-reqwest",
"dep:reqwest-middleware",
"dep:tokio",
"dep:futures",
]
gitlab = ["remote"]
## Enable integration with Bitbucket.
## You can turn this off if you don't use Bitbucket and don't want
## to make network requests to the Bitbucket API.
bitbucket = [
"dep:reqwest",
"dep:http-cache-reqwest",
"dep:reqwest-middleware",
"dep:tokio",
"dep:futures",
]
bitbucket = ["remote"]
## Enable integration with Gitea.
## You can turn this off if you don't use Bitbucket and don't want
## to make network requests to the Gitea API.
gitea = ["remote"]

[dependencies]
glob = { workspace = true, optional = true }
Expand Down Expand Up @@ -78,8 +71,9 @@ tokio = { version = "1.38.0", features = [
"macros",
], optional = true }
futures = { version = "0.3.30", optional = true }
url = "2.5.0"
url = { version = "2.5.0", features = ["serde"] }
dyn-clone = "1.0.17"
async-trait = "0.1.80"

[dependencies.git2]
version = "0.18.3"
Expand All @@ -102,6 +96,7 @@ features = ["debug-embed", "compression"]
[dev-dependencies]
pretty_assertions = "1.4.0"
expect-test = "1.5.0"
velcro = "0.5.4"

[package.metadata.docs.rs]
all-features = true
Expand Down
Loading
Loading