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

feat: Submodule commit processing #1082

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2d86ab6
feat(repo): get submodule repositories with commit ranges
lehmanju Mar 7, 2025
9b136a9
more submodule work on releases
lehmanju Mar 7, 2025
9320311
its working, yay
lehmanju Mar 7, 2025
f51d465
fix tests and other stuff
lehmanju Mar 7, 2025
094adce
rename some stuff and add if gate to submodule processing
lehmanju Mar 7, 2025
ef5c006
format
lehmanju Mar 7, 2025
feabec9
update cargo.toml
lehmanju Mar 17, 2025
d92a4f0
Update git-cliff-core/src/repo.rs
lehmanju Mar 17, 2025
1ad06e4
add submodule_commits comment
lehmanju Mar 17, 2025
1ca62e4
rename path fn
lehmanju Mar 17, 2025
229e007
revert formatting
lehmanju Mar 17, 2025
4db1481
more doc
lehmanju Mar 17, 2025
5156b85
format
lehmanju Mar 17, 2025
777d3cb
rename serde submodule_commits
lehmanju Mar 17, 2025
88dc46e
use hashmap, do preprocessing
lehmanju Mar 17, 2025
66f19cf
revert cargo.toml changes
lehmanju Mar 17, 2025
e816ec9
initial submodule test fixture
lehmanju Mar 17, 2025
5d2dda1
fix first/last commit
lehmanju Mar 17, 2025
c318056
fix syntax error in action
lehmanju Mar 18, 2025
7a1f23f
removed option from submodule commits -> cleaner templating
lehmanju Mar 18, 2025
2d9773b
add doc about submodules
lehmanju Mar 18, 2025
8d4c04b
fix integration test
lehmanju Mar 18, 2025
9e8b649
revert action changes
lehmanju Mar 18, 2025
6549b39
fix no commits in unreleased release
lehmanju Mar 19, 2025
1ee15c5
fix first/last release with no commits
lehmanju Mar 24, 2025
aab9cd9
Merge remote-tracking branch 'origin/main' into submodules-2
lehmanju Mar 24, 2025
53d428c
make test local only
lehmanju Mar 24, 2025
4a55cfd
add trace log
lehmanju Mar 24, 2025
eb673d3
Update website/docs/configuration/git.md
lehmanju Mar 24, 2025
f559b83
renaming and code doc
lehmanju Mar 24, 2025
3aba36e
debug for submodulerange not possible
lehmanju Mar 24, 2025
8f06ef7
fix context tests
lehmanju Mar 24, 2025
5f5b9c0
remove obsolete comment
lehmanju Mar 24, 2025
72b9050
add doc about submodule usage in template
lehmanju Mar 24, 2025
ffdc6c4
allow releases with no commits
lehmanju Mar 24, 2025
2f7898c
add fixture test for include path
lehmanju Mar 24, 2025
7040303
fix fixture test
lehmanju Mar 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -375,13 +375,15 @@
"timestamp": 0,
"previous": null,
"repository": null,
"submodule_commits": {},
"extra": null,
"github": { "contributors": [] },
"gitlab": { "contributors": [] },
"gitea": { "contributors": [] },
"bitbucket": { "contributors": [] }
},
"repository": "/path/to/repository",
"submodule_commits": {},
"extra": null,
"github": { "contributors": [] },
"gitlab": { "contributors": [] },
6 changes: 6 additions & 0 deletions .github/fixtures/test-from-context/context.json
Original file line number Diff line number Diff line change
@@ -160,6 +160,7 @@
"timestamp": 1649201112,
"previous": null,
"repository": "/home/johndoe/repo/",
"submodule_commits": {},
"github": {
"contributors": []
},
@@ -174,6 +175,7 @@
}
},
"repository": "/home/johndoe/repo/",
"submodule_commits": {},
"github": {
"contributors": []
},
@@ -449,6 +451,7 @@
"timestamp": 1649201110,
"previous": null,
"repository": "/home/johndoe/repo/",
"submodule_commits": {},
"github": {
"contributors": []
},
@@ -466,6 +469,7 @@
"note": "This is so awesome!"
},
"repository": "/home/johndoe/repo/",
"submodule_commits": {},
"github": {
"contributors": []
},
@@ -596,6 +600,7 @@
"timestamp": 0,
"previous": null,
"repository": null,
"submodule_commits": {},
"github": {
"contributors": []
},
@@ -610,6 +615,7 @@
}
},
"repository": "/home/johndoe/repo/",
"submodule_commits": {},
"github": {
"contributors": []
},
52 changes: 52 additions & 0 deletions .github/fixtures/test-submodules-include-path/cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration

[changelog]
# A Tera template to be rendered as the changelog's header.
# See https://keats.github.io/tera/docs/#introduction
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# A Tera template to be rendered for each release in the changelog.
# See https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\
{% for submodule_path, commits in submodule_commits %}
### {{ submodule_path | upper_first }}
{% for group, commits in commits | group_by(attribute="group") %}
#### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}
{% endfor %}\n
"""
# A Tera template to be rendered as the changelog's footer.
# See https://keats.github.io/tera/docs/#introduction
footer = """
<!-- generated by git-cliff -->
"""
# Remove leading and trailing whitespaces from the changelog's body.
trim = true

[git]
# An array of regex based parsers for extracting data from the commit message.
# Assigns commits to groups.
# Optionally sets the commit's `scope` and can decide to exclude commits from further processing.
commit_parsers = [
{ message = "^feat", group = "Features", default_scope = "app" },
{ message = "^fix", group = "Bug Fixes", scope = "cli" },
{ message = "^ci", group = "Continuous Integration" },
]
recurse_submodules = true
42 changes: 42 additions & 0 deletions .github/fixtures/test-submodules-include-path/commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -e

current_dir="$(pwd)"
submodule_one_dir="$(mktemp -d)"
submodule_two_dir="$(mktemp -d)"

cd $submodule_one_dir && git init >&2
GIT_COMMITTER_DATE="2022-04-05 01:00:8" git commit --allow-empty -m "feat: submodule_one initial commit"

cd $submodule_two_dir && git init >&2
GIT_COMMITTER_DATE="2022-04-05 01:00:12" git commit --allow-empty -m "feat: submodule_two feature B"

cd $current_dir
GIT_COMMITTER_DATE="2022-04-06 01:25:08" git commit --allow-empty -m "Initial commit"

git -c protocol.file.allow=always submodule add $submodule_one_dir submodule_one
GIT_COMMITTER_DATE="2022-04-06 01:25:09" git commit -a -m "feat: add submodule_one"

cd submodule_one
GIT_COMMITTER_DATE="2022-04-05 01:00:10" git commit --allow-empty -m "feat: submodule_one feature A"
GIT_COMMITTER_DATE="2022-04-05 01:00:11" git commit --allow-empty -m "fix: submodule_one fix A"
cd ..

GIT_COMMITTER_DATE="2022-04-06 01:25:10" git commit -a -m "feat: submodule_one update 1"
git tag v0.1.0

git -c protocol.file.allow=always submodule add $submodule_two_dir submodule_two
GIT_COMMITTER_DATE="2022-04-06 01:25:11" git commit -a -m "feat: submodule_two with initial commits"

cd submodule_two
GIT_COMMITTER_DATE="2022-04-05 01:00:13" git commit --allow-empty -m "fix: submodule_two fix B"
cd ..

GIT_COMMITTER_DATE="2022-04-06 01:25:12" git commit -a -m "feat: submodule_two update 1"
git tag v0.2.0

cd submodule_two
GIT_COMMITTER_DATE="2022-04-05 01:00:14" git commit --allow-empty -m "fix: submodule_two fix C"
cd ..

GIT_COMMITTER_DATE="2022-04-06 01:25:13" git commit -a -m "feat: submodule_two update 2"
48 changes: 48 additions & 0 deletions .github/fixtures/test-submodules-include-path/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Changelog

All notable changes to this project will be documented in this file.

## [unreleased]

### Features

- Submodule_two update 2

### Submodule_two

#### Bug Fixes

- Submodule_two fix C


## [0.2.0] - 2022-04-06

### Features

- Submodule_two with initial commits
- Submodule_two update 1

### Submodule_one

#### Bug Fixes

- Submodule_one fix A

#### Features

- Submodule_one feature A
- Submodule_one initial commit


### Submodule_two

#### Bug Fixes

- Submodule_two fix B

#### Features

- Submodule_two feature B


<!-- generated by git-cliff -->
52 changes: 52 additions & 0 deletions .github/fixtures/test-submodules/cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration

[changelog]
# A Tera template to be rendered as the changelog's header.
# See https://keats.github.io/tera/docs/#introduction
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# A Tera template to be rendered for each release in the changelog.
# See https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\
{% for submodule_path, commits in submodule_commits %}
### {{ submodule_path | upper_first }}
{% for group, commits in commits | group_by(attribute="group") %}
#### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}
{% endfor %}\n
"""
# A Tera template to be rendered as the changelog's footer.
# See https://keats.github.io/tera/docs/#introduction
footer = """
<!-- generated by git-cliff -->
"""
# Remove leading and trailing whitespaces from the changelog's body.
trim = true

[git]
# An array of regex based parsers for extracting data from the commit message.
# Assigns commits to groups.
# Optionally sets the commit's `scope` and can decide to exclude commits from further processing.
commit_parsers = [
{ message = "^feat", group = "Features", default_scope = "app" },
{ message = "^fix", group = "Bug Fixes", scope = "cli" },
{ message = "^ci", group = "Continuous Integration" },
]
recurse_submodules = true
42 changes: 42 additions & 0 deletions .github/fixtures/test-submodules/commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -e

current_dir="$(pwd)"
submodule_one_dir="$(mktemp -d)"
submodule_two_dir="$(mktemp -d)"

cd $submodule_one_dir && git init >&2
GIT_COMMITTER_DATE="2022-04-05 01:00:8" git commit --allow-empty -m "feat: submodule_one initial commit"

cd $submodule_two_dir && git init >&2
GIT_COMMITTER_DATE="2022-04-05 01:00:12" git commit --allow-empty -m "feat: submodule_two feature B"

cd $current_dir
GIT_COMMITTER_DATE="2022-04-06 01:25:08" git commit --allow-empty -m "Initial commit"

git -c protocol.file.allow=always submodule add $submodule_one_dir submodule_one
GIT_COMMITTER_DATE="2022-04-06 01:25:09" git commit -a -m "feat: add submodule_one"

cd submodule_one
GIT_COMMITTER_DATE="2022-04-05 01:00:10" git commit --allow-empty -m "feat: submodule_one feature A"
GIT_COMMITTER_DATE="2022-04-05 01:00:11" git commit --allow-empty -m "fix: submodule_one fix A"
cd ..

GIT_COMMITTER_DATE="2022-04-06 01:25:10" git commit -a -m "feat: submodule_one update 1"
git tag v0.1.0

git -c protocol.file.allow=always submodule add $submodule_two_dir submodule_two
GIT_COMMITTER_DATE="2022-04-06 01:25:11" git commit -a -m "feat: submodule_two with initial commits"

cd submodule_two
GIT_COMMITTER_DATE="2022-04-05 01:00:13" git commit --allow-empty -m "fix: submodule_two fix B"
cd ..

GIT_COMMITTER_DATE="2022-04-06 01:25:12" git commit -a -m "feat: submodule_two update 1"
git tag v0.2.0

cd submodule_two
GIT_COMMITTER_DATE="2022-04-05 01:00:14" git commit --allow-empty -m "fix: submodule_two fix C"
cd ..

GIT_COMMITTER_DATE="2022-04-06 01:25:13" git commit -a -m "feat: submodule_two update 2"
55 changes: 55 additions & 0 deletions .github/fixtures/test-submodules/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Changelog

All notable changes to this project will be documented in this file.

## [unreleased]

### Features

- Submodule_two update 2

### Submodule_two

#### Bug Fixes

- Submodule_two fix C


## [0.2.0] - 2022-04-06

### Features

- Submodule_two with initial commits
- Submodule_two update 1

### Submodule_two

#### Bug Fixes

- Submodule_two fix B

#### Features

- Submodule_two feature B


## [0.1.0] - 2022-04-06

### Features

- Add submodule_one
- Submodule_one update 1

### Submodule_one

#### Bug Fixes

- Submodule_one fix A

#### Features

- Submodule_one feature A
- Submodule_one initial commit


<!-- generated by git-cliff -->
3 changes: 3 additions & 0 deletions .github/workflows/test-fixtures.yml
Original file line number Diff line number Diff line change
@@ -108,6 +108,9 @@ jobs:
command: v2.6.1..v2.7.0 --include-path .github/fixtures/
- fixtures-name: test-require-conventional-negative
- fixtures-name: test-require-conventional-skipped
- fixtures-name: test-submodules
- fixtures-name: test-submodules-include-path
command: --include-path submodule_two
- fixtures-name: test-remote-config
command: --config-url "https://github.com/orhun/git-cliff/blob/main/.github/fixtures/new-fixture-template/cliff.toml?raw=true"

Loading