mirror of
https://github.com/hanzoui/registry-backend.git
synced 2026-10-30 20:30:45 +00:00
233 lines
8.2 KiB
Go
233 lines
8.2 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"registry-backend/ent/gitcommit"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// GitCommit is the model entity for the GitCommit schema.
|
|
type GitCommit struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// CreateTime holds the value of the "create_time" field.
|
|
CreateTime time.Time `json:"create_time,omitempty"`
|
|
// UpdateTime holds the value of the "update_time" field.
|
|
UpdateTime time.Time `json:"update_time,omitempty"`
|
|
// CommitHash holds the value of the "commit_hash" field.
|
|
CommitHash string `json:"commit_hash,omitempty"`
|
|
// BranchName holds the value of the "branch_name" field.
|
|
BranchName string `json:"branch_name,omitempty"`
|
|
// RepoName holds the value of the "repo_name" field.
|
|
RepoName string `json:"repo_name,omitempty"`
|
|
// CommitMessage holds the value of the "commit_message" field.
|
|
CommitMessage string `json:"commit_message,omitempty"`
|
|
// CommitTimestamp holds the value of the "commit_timestamp" field.
|
|
CommitTimestamp time.Time `json:"commit_timestamp,omitempty"`
|
|
// Author holds the value of the "author" field.
|
|
Author string `json:"author,omitempty"`
|
|
// Timestamp holds the value of the "timestamp" field.
|
|
Timestamp time.Time `json:"timestamp,omitempty"`
|
|
// PrNumber holds the value of the "pr_number" field.
|
|
PrNumber string `json:"pr_number,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the GitCommitQuery when eager-loading is set.
|
|
Edges GitCommitEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// GitCommitEdges holds the relations/edges for other nodes in the graph.
|
|
type GitCommitEdges struct {
|
|
// Results holds the value of the results edge.
|
|
Results []*CIWorkflowResult `json:"results,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [1]bool
|
|
}
|
|
|
|
// ResultsOrErr returns the Results value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e GitCommitEdges) ResultsOrErr() ([]*CIWorkflowResult, error) {
|
|
if e.loadedTypes[0] {
|
|
return e.Results, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "results"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*GitCommit) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case gitcommit.FieldCommitHash, gitcommit.FieldBranchName, gitcommit.FieldRepoName, gitcommit.FieldCommitMessage, gitcommit.FieldAuthor, gitcommit.FieldPrNumber:
|
|
values[i] = new(sql.NullString)
|
|
case gitcommit.FieldCreateTime, gitcommit.FieldUpdateTime, gitcommit.FieldCommitTimestamp, gitcommit.FieldTimestamp:
|
|
values[i] = new(sql.NullTime)
|
|
case gitcommit.FieldID:
|
|
values[i] = new(uuid.UUID)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the GitCommit fields.
|
|
func (gc *GitCommit) assignValues(columns []string, values []any) error {
|
|
if m, n := len(values), len(columns); m < n {
|
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
|
}
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case gitcommit.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
gc.ID = *value
|
|
}
|
|
case gitcommit.FieldCreateTime:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field create_time", values[i])
|
|
} else if value.Valid {
|
|
gc.CreateTime = value.Time
|
|
}
|
|
case gitcommit.FieldUpdateTime:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field update_time", values[i])
|
|
} else if value.Valid {
|
|
gc.UpdateTime = value.Time
|
|
}
|
|
case gitcommit.FieldCommitHash:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field commit_hash", values[i])
|
|
} else if value.Valid {
|
|
gc.CommitHash = value.String
|
|
}
|
|
case gitcommit.FieldBranchName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field branch_name", values[i])
|
|
} else if value.Valid {
|
|
gc.BranchName = value.String
|
|
}
|
|
case gitcommit.FieldRepoName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field repo_name", values[i])
|
|
} else if value.Valid {
|
|
gc.RepoName = value.String
|
|
}
|
|
case gitcommit.FieldCommitMessage:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field commit_message", values[i])
|
|
} else if value.Valid {
|
|
gc.CommitMessage = value.String
|
|
}
|
|
case gitcommit.FieldCommitTimestamp:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field commit_timestamp", values[i])
|
|
} else if value.Valid {
|
|
gc.CommitTimestamp = value.Time
|
|
}
|
|
case gitcommit.FieldAuthor:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field author", values[i])
|
|
} else if value.Valid {
|
|
gc.Author = value.String
|
|
}
|
|
case gitcommit.FieldTimestamp:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field timestamp", values[i])
|
|
} else if value.Valid {
|
|
gc.Timestamp = value.Time
|
|
}
|
|
case gitcommit.FieldPrNumber:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field pr_number", values[i])
|
|
} else if value.Valid {
|
|
gc.PrNumber = value.String
|
|
}
|
|
default:
|
|
gc.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the GitCommit.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (gc *GitCommit) Value(name string) (ent.Value, error) {
|
|
return gc.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryResults queries the "results" edge of the GitCommit entity.
|
|
func (gc *GitCommit) QueryResults() *CIWorkflowResultQuery {
|
|
return NewGitCommitClient(gc.config).QueryResults(gc)
|
|
}
|
|
|
|
// Update returns a builder for updating this GitCommit.
|
|
// Note that you need to call GitCommit.Unwrap() before calling this method if this GitCommit
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (gc *GitCommit) Update() *GitCommitUpdateOne {
|
|
return NewGitCommitClient(gc.config).UpdateOne(gc)
|
|
}
|
|
|
|
// Unwrap unwraps the GitCommit entity that was returned from a transaction after it was closed,
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
|
func (gc *GitCommit) Unwrap() *GitCommit {
|
|
_tx, ok := gc.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: GitCommit is not a transactional entity")
|
|
}
|
|
gc.config.driver = _tx.drv
|
|
return gc
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (gc *GitCommit) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("GitCommit(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", gc.ID))
|
|
builder.WriteString("create_time=")
|
|
builder.WriteString(gc.CreateTime.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("update_time=")
|
|
builder.WriteString(gc.UpdateTime.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("commit_hash=")
|
|
builder.WriteString(gc.CommitHash)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("branch_name=")
|
|
builder.WriteString(gc.BranchName)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("repo_name=")
|
|
builder.WriteString(gc.RepoName)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("commit_message=")
|
|
builder.WriteString(gc.CommitMessage)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("commit_timestamp=")
|
|
builder.WriteString(gc.CommitTimestamp.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("author=")
|
|
builder.WriteString(gc.Author)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("timestamp=")
|
|
builder.WriteString(gc.Timestamp.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("pr_number=")
|
|
builder.WriteString(gc.PrNumber)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// GitCommits is a parsable slice of GitCommit.
|
|
type GitCommits []*GitCommit
|