-
-
Notifications
You must be signed in to change notification settings - Fork 269
Closed
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is neededintegrationRelated to remote integrationRelated to remote integration
Description
Is there an existing issue for this?
- I have searched the existing issues
Description of the bug
In the following scenario:
- User foo contributes for the first time.
- New release is created and changelog is generated.
- User foo contributes after the release.
- New release is created and changelog is generated BUT user foo is removed from the first contributors section from the previous release.
Might be related to #825
Steps To Reproduce
See above.
Expected behavior
This happens due to not checking the dates of the new commits while updating the release metadata.
git-cliff/git-cliff-core/src/remote/mod.rs
Lines 337 to 347 in 8d10edb
| // mark contributors as first-time | |
| self.$remote.contributors = contributors | |
| .into_iter() | |
| .map(|mut v| { | |
| v.is_first_time = !commits | |
| .iter() | |
| .map(|v| v.username()) | |
| .any(|login| login == v.username); | |
| v | |
| }) | |
| .collect(); |
Here, we check all the commits, but you see, in the new release user foo already contributed, so his contribution is not marked as first time anymore.
To fix it, we should simply:
diff --git a/git-cliff-core/src/remote/mod.rs b/git-cliff-core/src/remote/mod.rs
index 77d14e7..32e61a9 100644
--- a/git-cliff-core/src/remote/mod.rs
+++ b/git-cliff-core/src/remote/mod.rs
@@ -83,6 +83,8 @@ pub trait RemoteCommit: DynClone {
fn id(&self) -> String;
/// Commit author.
fn username(&self) -> Option<String>;
+ /// Timestamp.
+ fn timestamp(&self) -> Option<i64>;
}
dyn_clone::clone_trait_object!(RemoteCommit);
@@ -340,6 +342,9 @@ macro_rules! update_release_metadata {
.map(|mut v| {
v.is_first_time = !commits
.iter()
+ .filter(|commit| {
+ commit.timestamp() < Some(self.timestamp)
+ })
.map(|v| v.username())
.any(|login| login == v.username);
vApply the patch above and you will see that we are missing the implementation for GitHub, GitLab, etc. We need to check each remote and add the appropriate field for serializing the timestamp from their API response.
Screenshots / Logs
nA
Software information
nA
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is neededintegrationRelated to remote integrationRelated to remote integration