mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-28 08:34:53 -04:00
feat: Add YYYY-MM-DD date format support for Pagure milestone migration (#10299)
Some checks are pending
/ release (push) Waiting to run
testing-integration / test-unit (push) Waiting to run
testing-integration / test-sqlite (push) Waiting to run
testing-integration / test-mariadb (v10.6) (push) Waiting to run
testing-integration / test-mariadb (v11.8) (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Some checks are pending
/ release (push) Waiting to run
testing-integration / test-unit (push) Waiting to run
testing-integration / test-sqlite (push) Waiting to run
testing-integration / test-mariadb (v10.6) (push) Waiting to run
testing-integration / test-mariadb (v11.8) (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
The change migrates the milestone's deadline in a semantic time format understood by the database. Please note that this change is in addition to that of !10169. Fixes https://forge.fedoraproject.org/forge/forge/issues/306 Signed-off-by: Akashdeep Dhar <akashdeep.dhar@gmail.com> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10299 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Akashdeep Dhar <akashdeep.dhar@gmail.com> Co-committed-by: Akashdeep Dhar <akashdeep.dhar@gmail.com>
This commit is contained in:
parent
91575ca285
commit
be43dbfcfb
2 changed files with 50 additions and 3 deletions
|
|
@ -178,13 +178,20 @@ func processDate(dateStr *string) time.Time {
|
|||
return date
|
||||
}
|
||||
|
||||
// Try parsing as Unix timestamp first
|
||||
unix, err := strconv.Atoi(*dateStr)
|
||||
if err != nil {
|
||||
log.Error("Error:", err)
|
||||
if err == nil {
|
||||
date = time.Unix(int64(unix), 0)
|
||||
return date
|
||||
}
|
||||
|
||||
date = time.Unix(int64(unix), 0)
|
||||
// Try parsing as YYYY-MM-DD format
|
||||
parsedDate, err := time.Parse("2006-01-02", *dateStr)
|
||||
if err == nil {
|
||||
return parsedDate
|
||||
}
|
||||
|
||||
log.Error("Error parsing date '%s': %v", *dateStr, err)
|
||||
return date
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -635,3 +635,43 @@ func TestPagureDownloadRepoWithPrivateIssues(t *testing.T) {
|
|||
},
|
||||
}, comments)
|
||||
}
|
||||
|
||||
func TestProcessDate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *string
|
||||
expected time.Time
|
||||
}{
|
||||
{
|
||||
name: "nil input",
|
||||
input: nil,
|
||||
expected: time.Time{},
|
||||
},
|
||||
{
|
||||
name: "empty string",
|
||||
input: strPtr(""),
|
||||
expected: time.Time{},
|
||||
},
|
||||
{
|
||||
name: "unix timestamp",
|
||||
input: strPtr("1609459200"),
|
||||
expected: time.Unix(1609459200, 0),
|
||||
},
|
||||
{
|
||||
name: "YYYY-MM-DD format",
|
||||
input: strPtr("2025-12-12"),
|
||||
expected: time.Date(2025, time.December, 12, 0, 0, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := processDate(tt.input)
|
||||
assert.Equal(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func strPtr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue