mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
2978 files. The fork is 2026-07-15 (rebrand: gitea.dev -> github.com/hanzoai/git), so 2026 is the year, and "Copyright 2026 Hanzo AI, Inc." was already the form used by the handful of files that had ours. Shape is now: // Copyright 2026 Hanzo AI, Inc. All rights reserved. // Copyright 2015 The Gogs Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT Ours on top, theirs retained verbatim. Retained because MIT requires it, and separately because they are true — those authors did write that code. Not renamed to "The Git Authors": Git is a different project under a different license, and putting its name here would attribute this code to people who have nothing to do with it. Adding our line is the fix; overwriting theirs would have been both a licence violation and a false statement. gofmt still reports import-order drift in some of these files. It predates this change (verified against a stash) and is left alone rather than burying a one-line-per-file legal change under 3000 files of unrelated reordering. Build clean. Co-authored-by: Hanzo Dev <[email protected]>
51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// Copyright 2015 The Gogs Authors. All rights reserved.
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package git
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/hanzoai/git/modules/log"
|
|
)
|
|
|
|
// Helper to get a signature from the commit line, which looks like:
|
|
//
|
|
// full name <[email protected]> 1378823654 +0200
|
|
//
|
|
// Haven't found the official reference for the standard format yet.
|
|
// This function never fails, if the "line" can't be parsed, it returns a default Signature with "zero" time.
|
|
func parseSignatureFromCommitLine(line string) *Signature {
|
|
sig := &Signature{}
|
|
s1, sx, ok1 := strings.Cut(line, " <")
|
|
s2, s3, ok2 := strings.Cut(sx, "> ")
|
|
if !ok1 || !ok2 {
|
|
sig.Name = line
|
|
return sig
|
|
}
|
|
sig.Name, sig.Email = s1, s2
|
|
|
|
if strings.Count(s3, " ") == 1 {
|
|
ts, tz, _ := strings.Cut(s3, " ")
|
|
seconds, _ := strconv.ParseInt(ts, 10, 64)
|
|
if tzTime, err := time.Parse("-0700", tz); err == nil {
|
|
sig.When = time.Unix(seconds, 0).In(tzTime.Location())
|
|
}
|
|
} else {
|
|
// the old gitea code tried to parse the date in a few different formats, but it's not clear why.
|
|
// according to public document, only the standard format "timestamp timezone" could be found, so drop other formats.
|
|
log.Error("suspicious commit line format: %q", line)
|
|
for _, fmt := range []string{ /*"Mon Jan _2 15:04:05 2006 -0700"*/ } {
|
|
if t, err := time.Parse(fmt, s3); err == nil {
|
|
sig.When = t
|
|
break
|
|
}
|
|
}
|
|
}
|
|
return sig
|
|
}
|