Update + signing of the binaries

This commit is contained in:
2025-12-15 00:46:20 +00:00
parent 4aab8af16f
commit 8423b6ada1
23 changed files with 269 additions and 983 deletions
-23
View File
@@ -26,26 +26,3 @@ type Commit struct {
// Derived fields
HasTests bool `json:"has_tests"`
}
// TotalChanges returns the total lines changed (additions + deletions)
func (c *Commit) TotalChanges() int {
return c.Additions + c.Deletions
}
// ShortSHA returns the first 7 characters of the SHA
func (c *Commit) ShortSHA() string {
if len(c.SHA) >= 7 {
return c.SHA[:7]
}
return c.SHA
}
// ShortMessage returns the first line of the commit message
func (c *Commit) ShortMessage() string {
for i, r := range c.Message {
if r == '\n' {
return c.Message[:i]
}
}
return c.Message
}
+8 -1
View File
@@ -63,7 +63,14 @@ type ContributorMetrics struct {
NightOwlCount int `json:"night_owl_count"` // Commits after 9pm
MidnightCount int `json:"midnight_count"` // Commits between midnight and 4am
WeekendWarrior int `json:"weekend_warrior"` // Weekend commits
OutOfHoursCount int `json:"out_of_hours_count"` // Commits outside 9am-5pm
OutOfHoursCount int `json:"out_of_hours_count"` // Commits outside 9am-5pm (legacy, kept for achievements)
// Time-based commit counts for multiplier scoring
RegularHoursCount int `json:"regular_hours_count"` // Commits 9am-5pm (x1 multiplier)
EveningCount int `json:"evening_count"` // Commits 5pm-9pm (x2 multiplier)
LateNightCount int `json:"late_night_count"` // Commits 9pm-midnight (x2.5 multiplier)
OvernightCount int `json:"overnight_count"` // Commits midnight-6am (x5 multiplier)
EarlyMorningCount int `json:"early_morning_count"` // Commits 6am-9am (x2 multiplier)
// Repository participation
RepositoriesContributed []string `json:"repositories_contributed,omitempty"`
-75
View File
@@ -45,81 +45,6 @@ func TestAuthor_DisplayName(t *testing.T) {
}
}
func TestCommit_TotalChanges(t *testing.T) {
t.Parallel()
commit := Commit{Additions: 100, Deletions: 50}
assert.Equal(t, 150, commit.TotalChanges())
}
func TestCommit_ShortSHA(t *testing.T) {
t.Parallel()
tests := []struct {
name string
sha string
expected string
}{
{
name: "full SHA",
sha: "abc123456789def",
expected: "abc1234",
},
{
name: "short SHA",
sha: "abc",
expected: "abc",
},
{
name: "exactly 7 chars",
sha: "abc1234",
expected: "abc1234",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
commit := Commit{SHA: tt.sha}
assert.Equal(t, tt.expected, commit.ShortSHA())
})
}
}
func TestCommit_ShortMessage(t *testing.T) {
t.Parallel()
tests := []struct {
name string
message string
expected string
}{
{
name: "single line",
message: "Fix bug in login",
expected: "Fix bug in login",
},
{
name: "multiline",
message: "Fix bug in login\n\nThis fixes the issue where users couldn't log in.",
expected: "Fix bug in login",
},
{
name: "empty",
message: "",
expected: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
commit := Commit{Message: tt.message}
assert.Equal(t, tt.expected, commit.ShortMessage())
})
}
}
func TestPullRequest_IsMerged(t *testing.T) {
t.Parallel()
+60 -3
View File
@@ -53,6 +53,18 @@ func (c *Calculator) Calculate(metrics *models.GlobalMetrics) *models.GlobalMetr
existing.IssuesClosed += cm.IssuesClosed
existing.IssueComments += cm.IssueComments
existing.IssueReferencesInCommits += cm.IssueReferencesInCommits
// Activity pattern metrics (for achievements)
existing.EarlyBirdCount += cm.EarlyBirdCount
existing.NightOwlCount += cm.NightOwlCount
existing.MidnightCount += cm.MidnightCount
existing.WeekendWarrior += cm.WeekendWarrior
existing.OutOfHoursCount += cm.OutOfHoursCount
// Time-based commit counts (for multiplier scoring)
existing.RegularHoursCount += cm.RegularHoursCount
existing.EveningCount += cm.EveningCount
existing.LateNightCount += cm.LateNightCount
existing.OvernightCount += cm.OvernightCount
existing.EarlyMorningCount += cm.EarlyMorningCount
// Combine unique repositories
for _, r := range cm.RepositoriesContributed {
if !contains(existing.RepositoriesContributed, r) {
@@ -169,8 +181,53 @@ func (c *Calculator) calculateScore(cm *models.ContributorMetrics) models.Score
points := c.config.Scoring.Points
breakdown := models.ScoreBreakdown{}
// Commit points
breakdown.Commits = cm.CommitCount * points.Commit
// Get multipliers with defaults if not set
multRegular := points.MultiplierRegularHours
if multRegular == 0 {
multRegular = 1.0
}
multEvening := points.MultiplierEvening
if multEvening == 0 {
multEvening = 2.0
}
multLateNight := points.MultiplierLateNight
if multLateNight == 0 {
multLateNight = 2.5
}
multOvernight := points.MultiplierOvernight
if multOvernight == 0 {
multOvernight = 5.0
}
multEarlyMorning := points.MultiplierEarlyMorning
if multEarlyMorning == 0 {
multEarlyMorning = 2.0
}
// Commit points with time-based multipliers:
// - 9am-5pm: base × 1.0
// - 5pm-9pm: base × 2.0
// - 9pm-midnight: base × 2.5
// - midnight-6am: base × 5.0
// - 6am-9am: base × 2.0
baseCommitPoints := float64(points.Commit)
// Check if we have time-based breakdown data
timeBasedTotal := cm.RegularHoursCount + cm.EveningCount + cm.LateNightCount +
cm.OvernightCount + cm.EarlyMorningCount
var commitScore float64
if timeBasedTotal > 0 {
// Use time-based multipliers
commitScore = float64(cm.RegularHoursCount)*baseCommitPoints*multRegular +
float64(cm.EveningCount)*baseCommitPoints*multEvening +
float64(cm.LateNightCount)*baseCommitPoints*multLateNight +
float64(cm.OvernightCount)*baseCommitPoints*multOvernight +
float64(cm.EarlyMorningCount)*baseCommitPoints*multEarlyMorning
} else {
// Fallback: use CommitCount with regular hours multiplier (backwards compatibility)
commitScore = float64(cm.CommitCount) * baseCommitPoints * multRegular
}
breakdown.Commits = int(commitScore)
// Line change points - always use meaningful lines (excluding comments/whitespace)
// to accurately reflect actual code contribution
@@ -203,7 +260,7 @@ func (c *Calculator) calculateScore(cm *models.ContributorMetrics) models.Score
}
}
// Out of hours bonus (commits outside 9am-5pm)
// Out of hours bonus (legacy - kept for backwards compatibility but default is 0)
breakdown.OutOfHours = cm.OutOfHoursCount * points.OutOfHours
// Calculate total