mirror of https://github.com/harness/drone.git
Temporary rename info/alternates so --batch-all-objects doesn't follow it (#2039)
parent
6da5c93706
commit
d4ca33b82d
|
@ -93,18 +93,13 @@ func (c *Controller) PreReceive(
|
|||
return hook.Output{}, fmt.Errorf("failed to extend pre-receive hook: %w", err)
|
||||
}
|
||||
|
||||
// File size check currently checks all the blobs in alternate as well in the original repo dirs.
|
||||
// We want to check file size only in alternate dirs.
|
||||
// Temporarily comment out file size check until the solution is found.
|
||||
// TODO: find the way to check the blob size only in alternate dirs.
|
||||
|
||||
// err = c.checkFileSizeLimit(ctx, rgit, repo, in, &output)
|
||||
// if output.Error != nil {
|
||||
// return output, nil
|
||||
// }
|
||||
// if err != nil {
|
||||
// return hook.Output{}, err
|
||||
// }
|
||||
err = c.checkFileSizeLimit(ctx, rgit, repo, in, &output)
|
||||
if output.Error != nil {
|
||||
return output, nil
|
||||
}
|
||||
if err != nil {
|
||||
return hook.Output{}, err
|
||||
}
|
||||
|
||||
return output, nil
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import (
|
|||
"github.com/gotidy/ptr"
|
||||
)
|
||||
|
||||
// nolint:unused
|
||||
func (c *Controller) checkFileSizeLimit(
|
||||
ctx context.Context,
|
||||
rgit RestrictedGIT,
|
||||
|
|
|
@ -104,7 +104,6 @@ func FMTDuration(d time.Duration) string {
|
|||
return d.String()
|
||||
}
|
||||
|
||||
// nolint:unused
|
||||
func printOversizeFiles(
|
||||
output *hook.Output,
|
||||
oversizeFiles []git.FileInfo,
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/harness/gitness/errors"
|
||||
|
@ -306,6 +307,16 @@ func catFileBatchCheckAllObjects(
|
|||
repoPath string,
|
||||
gitObjDir string,
|
||||
) ([]parser.BatchCheckObject, error) {
|
||||
// "info/alternates" points to the original repository.
|
||||
const oldFilename = "/info/alternates"
|
||||
const newFilename = "/info/alternates.bkp"
|
||||
|
||||
// --batch-all-objects reports objects in the current repository and in all alternate directories.
|
||||
// We want to report objects in the current repository only.
|
||||
if err := os.Rename(gitObjDir+oldFilename, gitObjDir+newFilename); err != nil && !os.IsNotExist(err) {
|
||||
return nil, fmt.Errorf("failed to rename %s to %s: %w", oldFilename, newFilename, err)
|
||||
}
|
||||
|
||||
cmd := command.New("cat-file",
|
||||
command.WithFlag("--batch-check"),
|
||||
command.WithFlag("--batch-all-objects"),
|
||||
|
@ -328,5 +339,9 @@ func catFileBatchCheckAllObjects(
|
|||
return nil, fmt.Errorf("failed to parse output of cat-file batch check all objects: %w", err)
|
||||
}
|
||||
|
||||
if err := os.Rename(gitObjDir+newFilename, gitObjDir+oldFilename); err != nil && !os.IsNotExist(err) {
|
||||
return nil, fmt.Errorf("failed to rename %s to %s: %w", newFilename, oldFilename, err)
|
||||
}
|
||||
|
||||
return objects, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue