Suport for DOLT_AUTHOR_DATE in dolt commit

This commit is contained in:
Zach Musgrave
2023-09-26 12:00:00 -07:00
parent 929531d11c
commit ab8050d69c
3 changed files with 14 additions and 7 deletions

View File

@@ -23,6 +23,7 @@ import (
"github.com/dolthub/dolt/go/libraries/doltcore/dconfig"
"github.com/dolthub/dolt/go/libraries/doltcore/env/actions"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dsess"
"github.com/dolthub/dolt/go/store/datas"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/types"
)
@@ -131,6 +132,8 @@ func doDoltCommit(ctx *sql.Context, args []string) (string, bool, error) {
if err != nil {
return "", false, fmt.Errorf(err.Error())
}
} else if datas.CustomAuthorDate {
t = datas.AuthorDate()
}
if apr.Contains(cli.ForceFlag) {

View File

@@ -49,6 +49,7 @@ var CommitterDate = time.Now
var CommitLoc = time.Local
var AuthorDate = time.Now
var CustomAuthorDate bool
var AuthorLoc = time.Local
// CommitMeta contains all the metadata that is associated with a commit within a data repo.
@@ -73,9 +74,10 @@ func init() {
if err != nil {
logrus.Warnf("Unable to parse value for %s: %s. System time will be used instead.",
dconfig.EnvDoltCommitterDate, err.Error())
}
CommitterDate = func() time.Time {
return committerDate
} else {
CommitterDate = func() time.Time {
return committerDate
}
}
}
@@ -85,9 +87,11 @@ func init() {
if err != nil {
logrus.Warnf("Unable to parse value for %s: %s. System time will be used instead.",
dconfig.EnvDoltAuthorDate, err.Error())
}
AuthorDate = func() time.Time {
return authorDate
} else {
AuthorDate = func() time.Time {
return authorDate
}
CustomAuthorDate = true
}
}
}

View File

@@ -227,5 +227,5 @@ SQL
}
dolt_log_in_PST() {
TZ=PST-7 dolt log -n1
TZ=PST+8 dolt log -n1
}