Documentation
¶
Index ¶
- Variables
- func DoDiff(src, dst string) []diffmatchpatch.Diff
- func GetAuthorizedKeys(pubkeys []string) ([]ssh.PublicKey, error)
- func GitPatchRequestMiddleware(be *Backend, pr GitPatchRequest) wish.Middleware
- func GitSshServer(cfg *GitCfg, killCh chan error)
- func LoadConfigFile(fpath string, logger *slog.Logger)
- func NewCli(sesh ssh.Session, be *Backend, pr GitPatchRequest) *cli.App
- func NewTabWriter(out io.Writer) *tabwriter.Writer
- func ParsePatch(patchRaw string) ([]*gitdiff.File, string, error)
- func RangeDiffToStr(diffs []*RangeDiffOutput) string
- func SqliteOpen(dsn string, logger *slog.Logger) (*sqlx.DB, error)
- func StartWebServer(cfg *GitCfg)
- type Acl
- type Backend
- func (be *Backend) CanCreateRepo(repo *Repo, requester *User) error
- func (be *Backend) CreateRepoNs(userName, repoName string) string
- func (be *Backend) GetPatchRequestAcl(repo *Repo, prq *PatchRequest, requester *User) *PrAcl
- func (be *Backend) IsAdmin(pk ssh.PublicKey) bool
- func (be *Backend) IsPrOwner(pka, pkb int64) bool
- func (be *Backend) KeyForFingerprint(pk ssh.PublicKey) string
- func (be *Backend) KeyForKeyText(pk ssh.PublicKey) string
- func (be *Backend) KeysEqual(pka, pkb string) bool
- func (be *Backend) Pubkey(pk ssh.PublicKey) string
- func (be *Backend) PubkeyToPublicKey(pubkey string) (ssh.PublicKey, error)
- func (be *Backend) SplitRepoNs(repoNs string) (string, string)
- func (be *Backend) ValidateRepoNs(repoNs string) error
- type EventLog
- type EventLogData
- type GitCfg
- type GitPatchRequest
- type LinkData
- type MetaData
- type Patch
- type PatchData
- type PatchFile
- type PatchRange
- type PatchRequest
- type Patchset
- type PatchsetData
- type PatchsetOp
- type PrAcl
- type PrCmd
- func (cmd PrCmd) CreateEventLog(tx *sqlx.Tx, eventLog EventLog) error
- func (pr PrCmd) CreateRepo(user *User, repoName string) (*Repo, error)
- func (cmd PrCmd) DeletePatchsetByID(userID int64, prID int64, patchsetID int64) error
- func (cmd PrCmd) DiffPatchsets(prev *Patchset, next *Patchset) ([]*RangeDiffOutput, error)
- func (cmd PrCmd) GetEventLogs() ([]*EventLog, error)
- func (cmd PrCmd) GetEventLogsByPrID(prID int64) ([]*EventLog, error)
- func (cmd PrCmd) GetEventLogsByRepoName(user *User, repoName string) ([]*EventLog, error)
- func (cmd PrCmd) GetEventLogsByUserID(userID int64) ([]*EventLog, error)
- func (pr PrCmd) GetLatestPatchsetByPrID(prID int64) (*Patchset, error)
- func (cmd PrCmd) GetPatchRequestByID(prID int64) (*PatchRequest, error)
- func (cmd PrCmd) GetPatchRequests() ([]*PatchRequest, error)
- func (cmd PrCmd) GetPatchRequestsByRepoID(repoID int64) ([]*PatchRequest, error)
- func (pr PrCmd) GetPatchesByPatchsetID(patchsetID int64) ([]*Patch, error)
- func (pr PrCmd) GetPatchsetByID(patchsetID int64) (*Patchset, error)
- func (pr PrCmd) GetPatchsetsByPrID(prID int64) ([]*Patchset, error)
- func (pr PrCmd) GetRepoByID(repoID int64) (*Repo, error)
- func (pr PrCmd) GetRepoByName(user *User, repoName string) (*Repo, error)
- func (pr PrCmd) GetRepos() (repos []*Repo, err error)
- func (pr PrCmd) GetUserByID(id int64) (*User, error)
- func (pr PrCmd) GetUserByName(name string) (*User, error)
- func (pr PrCmd) GetUserByPubkey(pubkey string) (*User, error)
- func (pr PrCmd) GetUsers() ([]*User, error)
- func (pr PrCmd) IsBanned(pubkey, ipAddress string) error
- func (cmd PrCmd) SubmitPatchRequest(repoID int64, userID int64, patchset io.Reader) (*PatchRequest, error)
- func (cmd PrCmd) SubmitPatchset(prID int64, userID int64, op PatchsetOp, patchset io.Reader) ([]*Patch, error)
- func (cmd PrCmd) UpdatePatchRequestName(prID int64, userID int64, name string) error
- func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status string) error
- func (pr PrCmd) UpsertUser(pubkey, name string) (*User, error)
- type PrData
- type PrDetailData
- type PrListData
- type PrTableData
- type RangeDiffOutput
- type Repo
- type RepoDetailData
- type User
- type UserData
- type UserDetailData
- type WebCtx
Constants ¶
This section is empty.
Variables ¶
View Source
var COST_MAX = 65536
View Source
var ErrPatchExists = errors.New("patch already exists for patch request")
View Source
var ErrRepoNoNamespace = fmt.Errorf("repo must be namespaced by username")
View Source
var RANGE_DIFF_CREATION_FACTOR_DEFAULT = 60
Functions ¶
func DoDiff ¶ added in v0.3.0
func DoDiff(src, dst string) []diffmatchpatch.Diff
func GetAuthorizedKeys ¶ added in v0.3.0
func GitPatchRequestMiddleware ¶
func GitPatchRequestMiddleware(be *Backend, pr GitPatchRequest) wish.Middleware
func GitSshServer ¶
func LoadConfigFile ¶ added in v0.3.0
func RangeDiffToStr ¶ added in v0.3.0
func RangeDiffToStr(diffs []*RangeDiffOutput) string
func SqliteOpen ¶ added in v0.3.0
Open opens a database connection.
func StartWebServer ¶
func StartWebServer(cfg *GitCfg)
Types ¶
type Acl ¶
type Acl struct {
ID int64 `db:"id"`
Pubkey sql.NullString `db:"pubkey"`
IpAddress sql.NullString `db:"ip_address"`
Permission string `db:"permission"`
CreatedAt time.Time `db:"created_at"`
}
Acl is a db model for access control.
type Backend ¶
func (*Backend) CanCreateRepo ¶ added in v0.3.0
func (*Backend) CreateRepoNs ¶ added in v0.3.0
Repo Namespace.
func (*Backend) GetPatchRequestAcl ¶ added in v0.3.0
func (be *Backend) GetPatchRequestAcl(repo *Repo, prq *PatchRequest, requester *User) *PrAcl
func (*Backend) PubkeyToPublicKey ¶
func (*Backend) SplitRepoNs ¶ added in v0.3.0
func (*Backend) ValidateRepoNs ¶ added in v0.3.0
type EventLog ¶
type EventLog struct {
ID int64 `db:"id"`
UserID int64 `db:"user_id"`
RepoID sql.NullInt64 `db:"repo_id"`
PatchRequestID sql.NullInt64 `db:"patch_request_id"`
PatchsetID sql.NullInt64 `db:"patchset_id"`
Event string `db:"event"`
Data string `db:"data"`
CreatedAt time.Time `db:"created_at"`
}
EventLog is a event log for RSS or other notification systems.
type EventLogData ¶
type GitCfg ¶
type GitCfg struct {
DataDir string `koanf:"data_dir"`
Url string `koanf:"url"`
Host string `koanf:"host"`
SshPort string `koanf:"ssh_port"`
WebPort string `koanf:"web_port"`
AdminsStr []string `koanf:"admins"`
Admins []ssh.PublicKey `koanf:"admins_pk"`
CreateRepo string `koanf:"create_repo"`
Theme string `koanf:"theme"`
TimeFormat string `koanf:"time_format"`
Logger *slog.Logger
}
type GitPatchRequest ¶
type GitPatchRequest interface {
GetUsers() ([]*User, error)
GetUserByID(userID int64) (*User, error)
GetUserByName(name string) (*User, error)
GetUserByPubkey(pubkey string) (*User, error)
GetRepos() ([]*Repo, error)
GetRepoByID(repoID int64) (*Repo, error)
GetRepoByName(user *User, repoName string) (*Repo, error)
CreateRepo(user *User, repoName string) (*Repo, error)
UpsertUser(pubkey, name string) (*User, error)
IsBanned(pubkey, ipAddress string) error
SubmitPatchRequest(repoID int64, userID int64, patchset io.Reader) (*PatchRequest, error)
SubmitPatchset(prID, userID int64, op PatchsetOp, patchset io.Reader) ([]*Patch, error)
GetPatchRequestByID(prID int64) (*PatchRequest, error)
GetPatchRequests() ([]*PatchRequest, error)
GetPatchRequestsByRepoID(repoID int64) ([]*PatchRequest, error)
GetPatchsetsByPrID(prID int64) ([]*Patchset, error)
GetPatchsetByID(patchsetID int64) (*Patchset, error)
GetLatestPatchsetByPrID(prID int64) (*Patchset, error)
GetPatchesByPatchsetID(prID int64) ([]*Patch, error)
UpdatePatchRequestStatus(prID, userID int64, status string) error
UpdatePatchRequestName(prID, userID int64, name string) error
DeletePatchsetByID(userID, prID int64, patchsetID int64) error
CreateEventLog(tx *sqlx.Tx, eventLog EventLog) error
GetEventLogs() ([]*EventLog, error)
GetEventLogsByRepoName(user *User, repoName string) ([]*EventLog, error)
GetEventLogsByPrID(prID int64) ([]*EventLog, error)
GetEventLogsByUserID(userID int64) ([]*EventLog, error)
DiffPatchsets(aset *Patchset, bset *Patchset) ([]*RangeDiffOutput, error)
}
type Patch ¶
type Patch struct {
ID int64 `db:"id"`
UserID int64 `db:"user_id"`
PatchsetID int64 `db:"patchset_id"`
AuthorName string `db:"author_name"`
AuthorEmail string `db:"author_email"`
AuthorDate time.Time `db:"author_date"`
Title string `db:"title"`
Body string `db:"body"`
BodyAppendix string `db:"body_appendix"`
CommitSha string `db:"commit_sha"`
ContentSha string `db:"content_sha"`
BaseCommitSha sql.NullString `db:"base_commit_sha"`
RawText string `db:"raw_text"`
CreatedAt time.Time `db:"created_at"`
Files []*gitdiff.File
}
Patch is a database model for a single entry in a patchset. This usually corresponds to a git commit.
type PatchRange ¶ added in v0.3.0
func NewPatchRange ¶ added in v0.3.0
func NewPatchRange(patch *Patch) *PatchRange
type PatchRequest ¶
type PatchRequest struct {
ID int64 `db:"id"`
UserID int64 `db:"user_id"`
RepoID int64 `db:"repo_id"`
Name string `db:"name"`
Text string `db:"text"`
Status string `db:"status"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
// only used for aggregate queries
LastUpdated string `db:"last_updated"`
}
PatchRequest is a database model for patches submitted to a Repo.
type PatchsetData ¶
type PatchsetData struct {
*Patchset
UserData
FormattedID string
Date string
RangeDiff []*RangeDiffOutput
}
type PatchsetOp ¶
type PatchsetOp int
const ( OpNormal PatchsetOp = iota OpReview OpAccept OpClose )
type PrCmd ¶
type PrCmd struct {
Backend *Backend
}
func (PrCmd) CreateRepo ¶ added in v0.3.0
func (PrCmd) DeletePatchsetByID ¶
func (PrCmd) DiffPatchsets ¶
func (cmd PrCmd) DiffPatchsets(prev *Patchset, next *Patchset) ([]*RangeDiffOutput, error)
func (PrCmd) GetEventLogs ¶
func (PrCmd) GetEventLogsByPrID ¶
func (PrCmd) GetEventLogsByRepoName ¶ added in v0.3.0
func (PrCmd) GetEventLogsByUserID ¶
func (PrCmd) GetLatestPatchsetByPrID ¶
func (PrCmd) GetPatchRequestByID ¶
func (cmd PrCmd) GetPatchRequestByID(prID int64) (*PatchRequest, error)
func (PrCmd) GetPatchRequests ¶
func (cmd PrCmd) GetPatchRequests() ([]*PatchRequest, error)
func (PrCmd) GetPatchRequestsByRepoID ¶
func (cmd PrCmd) GetPatchRequestsByRepoID(repoID int64) ([]*PatchRequest, error)
func (PrCmd) GetPatchesByPatchsetID ¶
func (PrCmd) GetPatchsetByID ¶ added in v0.3.0
func (PrCmd) GetPatchsetsByPrID ¶
func (PrCmd) GetRepoByName ¶ added in v0.3.0
func (PrCmd) GetUserByName ¶ added in v0.3.0
func (PrCmd) SubmitPatchRequest ¶
func (PrCmd) SubmitPatchset ¶
func (PrCmd) UpdatePatchRequestName ¶
func (PrCmd) UpdatePatchRequestStatus ¶
Status types: open, closed, accepted, reviewed.
type PrDetailData ¶
type PrDetailData struct {
Page string
Repo LinkData
Pr PrData
Patchset *Patchset
Patches []PatchData
Branch string
Logs []EventLogData
Patchsets []PatchsetData
MetaData
}
type PrListData ¶
type PrTableData ¶ added in v0.3.0
type PrTableData struct {
Prs []*PrListData
MetaData
}
type RangeDiffOutput ¶ added in v0.3.0
type RangeDiffOutput struct {
Header string
Diff []diffmatchpatch.Diff
Type string
}
func RangeDiff ¶ added in v0.3.0
func RangeDiff(a []*Patch, b []*Patch) []*RangeDiffOutput
type Repo ¶
type Repo struct {
ID int64 `db:"id"`
Name string `db:"name"`
UserID int64 `db:"user_id"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
Repo is a container for patch requests.
type RepoDetailData ¶
type User ¶
type User struct {
ID int64 `db:"id"`
Pubkey string `db:"pubkey"`
Name string `db:"name"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
User is a db model for users.
type UserDetailData ¶ added in v0.3.0
type UserDetailData struct {
Prs []*PrListData
UserData UserData
MetaData
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.
