Detailed changes
@@ -58,7 +58,7 @@ func (b *Backend) ListAccessTokens(ctx context.Context, user proto.User) ([]prot
return nil, db.WrapError(err)
}
- var tokens []proto.AccessToken
+ tokens := make([]proto.AccessToken, 0, len(accessTokens))
for _, t := range accessTokens {
token := proto.AccessToken{
ID: t.ID,
@@ -62,7 +62,7 @@ func (d *Backend) Collaborators(ctx context.Context, repo string) ([]string, err
return nil, db.WrapError(err)
}
- var usernames []string
+ usernames := make([]string, 0, len(users))
for _, u := range users {
usernames = append(usernames, u.Username)
}
@@ -42,7 +42,7 @@ func (d *Backend) AccessLevelByPublicKey(ctx context.Context, repo string, pk ss
}
// AccessLevelForUser returns the access level of a user for a repository.
-// TODO: user repository ownership
+// TODO: user repository ownership.
func (d *Backend) AccessLevelForUser(ctx context.Context, repo string, user proto.User) access.AccessLevel {
var username string
anon := d.AnonAccess(ctx)
@@ -399,17 +399,17 @@ type user struct {
var _ proto.User = (*user)(nil)
-// IsAdmin implements proto.User
+// IsAdmin implements proto.User.
func (u *user) IsAdmin() bool {
return u.user.Admin
}
-// PublicKeys implements proto.User
+// PublicKeys implements proto.User.
func (u *user) PublicKeys() []ssh.PublicKey {
return u.publicKeys
}
-// Username implements proto.User
+// Username implements proto.User.
func (u *user) Username() string {
return u.user.Username
}
@@ -16,7 +16,7 @@ const (
createTablesName = "create tables"
createTablesVersion = 1
- // Database driver names
+ // Database driver names.
driverSQLite3 = "sqlite3"
driverSQLite = "sqlite"
driverPostgres = "postgres"
@@ -111,7 +111,7 @@ func (p Pointer) RelativePath() string {
return path.Join(p.Oid[0:2], p.Oid[2:4], p.Oid)
}
-// GeneratePointer generates a pointer for arbitrary content
+// GeneratePointer generates a pointer for arbitrary content.
func GeneratePointer(content io.Reader) (Pointer, error) {
h := sha256.New()
c, err := io.Copy(h, content)
@@ -14,7 +14,7 @@ import (
"github.com/charmbracelet/soft-serve/git"
)
-// SearchPointerBlobs scans the whole repository for LFS pointer files
+// SearchPointerBlobs scans the whole repository for LFS pointer files.
func SearchPointerBlobs(ctx context.Context, repo *git.Repository, pointerChan chan<- PointerBlob, errChan chan<- error) {
basePath := repo.Path
@@ -8,7 +8,7 @@ import (
// TransferBasic is the name of the Git LFS basic transfer protocol.
const TransferBasic = "basic"
-// TransferAdapter represents an adapter for downloading/uploading LFS objects
+// TransferAdapter represents an adapter for downloading/uploading LFS objects.
type TransferAdapter interface {
Name() string
Download(ctx context.Context, p Pointer, l *Link) (io.ReadCloser, error)
@@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
)
-// InfoCommand returns a command that shows the user's info
+// InfoCommand returns a command that shows the user's info.
func InfoCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "info",
@@ -79,7 +79,7 @@ func (l *LocalStorage) Rename(oldName, newName string) error {
return os.Rename(oldName, newName)
}
-// Replace all slashes with the OS-specific separator
+// Replace all slashes with the OS-specific separator.
func (l LocalStorage) fixPath(path string) string {
path = strings.ReplaceAll(path, "/", string(os.PathSeparator))
if !filepath.IsAbs(path) {
@@ -14,7 +14,7 @@ type Component interface {
}
// TabComponenet represents a model that is mounted to a tab.
-// TODO: find a better name
+// TODO: find a better name.
type TabComponent interface {
Component
@@ -455,7 +455,7 @@ func serviceRpc(w http.ResponseWriter, r *http.Request) {
}
// Handle buffered output
-// Useful when using proxies
+// Useful when using proxies.
type flushResponseWriter struct {
http.ResponseWriter
}
@@ -29,7 +29,7 @@ import (
// serviceLfsBatch handles a Git LFS batch requests.
// https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md
// TODO: support refname
-// POST: /<repo>.git/info/lfs/objects/batch
+// POST: /<repo>.git/info/lfs/objects/batch.
func serviceLfsBatch(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
logger := log.FromContext(ctx).WithPrefix("http.lfs")
@@ -249,7 +249,7 @@ func serviceLfsBasic(w http.ResponseWriter, r *http.Request) {
}
}
-// GET: /<repo>.git/info/lfs/objects/basic/<oid>
+// GET: /<repo>.git/info/lfs/objects/basic/<oid>.
func serviceLfsBasicDownload(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
oid := mux.Vars(r)["oid"]
@@ -292,7 +292,7 @@ func serviceLfsBasicDownload(w http.ResponseWriter, r *http.Request) {
}
}
-// PUT: /<repo>.git/info/lfs/objects/basic/<oid>
+// PUT: /<repo>.git/info/lfs/objects/basic/<oid>.
func serviceLfsBasicUpload(w http.ResponseWriter, r *http.Request) {
if !isBinary(r) {
renderJSON(w, http.StatusUnsupportedMediaType, lfs.ErrorResponse{
@@ -366,7 +366,7 @@ func serviceLfsBasicUpload(w http.ResponseWriter, r *http.Request) {
renderStatus(http.StatusOK)(w, nil)
}
-// POST: /<repo>.git/info/lfs/objects/basic/verify
+// POST: /<repo>.git/info/lfs/objects/basic/verify.
func serviceLfsBasicVerify(w http.ResponseWriter, r *http.Request) {
if !isLfs(r) {
renderNotAcceptable(w)
@@ -454,7 +454,7 @@ func serviceLfsLocks(w http.ResponseWriter, r *http.Request) {
}
}
-// POST: /<repo>.git/info/lfs/objects/locks
+// POST: /<repo>.git/info/lfs/objects/locks.
func serviceLfsLocksCreate(w http.ResponseWriter, r *http.Request) {
if !isLfs(r) {
renderNotAcceptable(w)
@@ -555,7 +555,7 @@ func serviceLfsLocksCreate(w http.ResponseWriter, r *http.Request) {
})
}
-// GET: /<repo>.git/info/lfs/objects/locks
+// GET: /<repo>.git/info/lfs/objects/locks.
func serviceLfsLocksGet(w http.ResponseWriter, r *http.Request) {
accept := r.Header.Get("Accept")
if !strings.HasPrefix(accept, lfs.MediaType) {
@@ -730,7 +730,7 @@ func serviceLfsLocksGet(w http.ResponseWriter, r *http.Request) {
renderJSON(w, http.StatusOK, resp)
}
-// POST: /<repo>.git/info/lfs/objects/locks/verify
+// POST: /<repo>.git/info/lfs/objects/locks/verify.
func serviceLfsLocksVerify(w http.ResponseWriter, r *http.Request) {
if !isLfs(r) {
renderNotAcceptable(w)
@@ -827,7 +827,7 @@ func serviceLfsLocksVerify(w http.ResponseWriter, r *http.Request) {
renderJSON(w, http.StatusOK, resp)
}
-// POST: /<repo>.git/info/lfs/objects/locks/:lockID/unlock
+// POST: /<repo>.git/info/lfs/objects/locks/:lockID/unlock.
func serviceLfsLocksDelete(w http.ResponseWriter, r *http.Request) {
if !isLfs(r) {
renderNotAcceptable(w)