Skip to content

Commit df60de2

Browse files
Fixing Merge errors - still few to go
1 parent 6a2e670 commit df60de2

File tree

6 files changed

+25
-64
lines changed

6 files changed

+25
-64
lines changed

models/repo/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ func (repo *Repository) computeSize() (int64, error) {
522522
return 0, fmt.Errorf("computeSize: %v", err)
523523
}
524524

525-
objs, err := repo.GetLFSMetaObjects(-1, 0)
525+
objs, err := repo.GetLFSMetaObjects(repo.ID, -1, 0)
526526
if err != nil {
527527
return 0, fmt.Errorf("computeSize: GetLFSMetaObjects: %v", err)
528528
}

modules/git/repo.go

Lines changed: 16 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -257,50 +257,6 @@ func Push(ctx context.Context, repoPath string, opts PushOptions) error {
257257
return err
258258
}
259259

260-
// CheckoutOptions options when heck out some branch
261-
type CheckoutOptions struct {
262-
Timeout time.Duration
263-
Branch string
264-
OldBranch string
265-
}
266-
267-
// Checkout checkouts a branch
268-
func Checkout(repoPath string, opts CheckoutOptions) error {
269-
cmd := NewCommand("checkout")
270-
if len(opts.OldBranch) > 0 {
271-
cmd.AddArguments("-b")
272-
}
273-
274-
if opts.Timeout <= 0 {
275-
opts.Timeout = -1
276-
}
277-
278-
cmd.AddArguments(opts.Branch)
279-
280-
if len(opts.OldBranch) > 0 {
281-
cmd.AddArguments(opts.OldBranch)
282-
}
283-
284-
_, err := cmd.RunInDirTimeout(opts.Timeout, repoPath)
285-
return err
286-
}
287-
288-
// ResetHEAD resets HEAD to given revision or head of branch.
289-
func ResetHEAD(repoPath string, hard bool, revision string) error {
290-
cmd := NewCommand("reset")
291-
if hard {
292-
cmd.AddArguments("--hard")
293-
}
294-
_, err := cmd.AddArguments(revision).RunInDir(repoPath)
295-
return err
296-
}
297-
298-
// MoveFile moves a file to another file or directory.
299-
func MoveFile(repoPath, oldTreeName, newTreeName string) error {
300-
_, err := NewCommand("mv").AddArguments(oldTreeName, newTreeName).RunInDir(repoPath)
301-
return err
302-
}
303-
304260
// CountObject represents repository count objects report
305261
type CountObject struct {
306262
Count int64
@@ -325,14 +281,14 @@ const (
325281
)
326282

327283
// CountObjects returns the results of git count-objects on the repoPath
328-
func CountObjects(repoPath string) (*CountObject, error) {
329-
return CountObjectsWithEnv(repoPath, nil)
284+
func CountObjects(ctx context.Context, repoPath string) (*CountObject, error) {
285+
return CountObjectsWithEnv(ctx, repoPath, nil)
330286
}
331287

332288
// CountObjectsWithEnv returns the results of git count-objects on the repoPath with custom env setup
333-
func CountObjectsWithEnv(repoPath string, env []string) (*CountObject, error) {
334-
cmd := NewCommand("count-objects", "-v")
335-
stdout, err := cmd.RunInDirWithEnv(repoPath, env)
289+
func CountObjectsWithEnv(ctx context.Context, repoPath string, env []string) (*CountObject, error) {
290+
cmd := NewCommand(ctx, "count-objects", "-v")
291+
stdout, _, err := cmd.RunStdString(&RunOpts{Dir: repoPath, Env: env})
336292
if err != nil {
337293
return nil, err
338294
}
@@ -346,21 +302,24 @@ func parseSize(objects string) *CountObject {
346302
for _, line := range strings.Split(objects, "\n") {
347303
switch {
348304
case strings.HasPrefix(line, statCount):
349-
repoSize.Count = com.StrTo(line[7:]).MustInt64()
305+
repoSize.Count, _ = strconv.ParseInt(line[7:], 10, 64)
350306
case strings.HasPrefix(line, statSize):
351-
repoSize.Size = com.StrTo(line[6:]).MustInt64() * 1024
307+
number, _ := strconv.ParseInt(line[6:], 10, 64)
308+
repoSize.Size = number * 1024
352309
case strings.HasPrefix(line, statInpack):
353-
repoSize.InPack = com.StrTo(line[9:]).MustInt64()
310+
repoSize.InPack, _ = strconv.ParseInt(line[9:], 10, 64)
354311
case strings.HasPrefix(line, statPacks):
355-
repoSize.Packs = com.StrTo(line[7:]).MustInt64()
312+
repoSize.Packs, _ = strconv.ParseInt(line[7:], 10, 64)
356313
case strings.HasPrefix(line, statSizePack):
357-
repoSize.SizePack = com.StrTo(line[11:]).MustInt64() * 1024
314+
number, _ := strconv.ParseInt(line[11:], 10, 64)
315+
repoSize.SizePack = number * 1024
358316
case strings.HasPrefix(line, statPrunePackage):
359-
repoSize.PrunePack = com.StrTo(line[16:]).MustInt64()
317+
repoSize.PrunePack, _ = strconv.ParseInt(line[16:], 10, 64)
360318
case strings.HasPrefix(line, statGarbage):
361-
repoSize.Garbage = com.StrTo(line[9:]).MustInt64()
319+
repoSize.Garbage, _ = strconv.ParseInt(line[9:], 10, 64)
362320
case strings.HasPrefix(line, statSizeGarbage):
363-
repoSize.SizeGarbage = com.StrTo(line[14:]).MustInt64() * 1024
321+
number, _ := strconv.ParseInt(line[14:], 10, 64)
322+
repoSize.SizeGarbage = number * 1024
364323
}
365324
}
366325
return repoSize

routers/api/v1/repo/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err
719719
if opts.SizeLimit != nil {
720720
repo.SizeLimit = *opts.SizeLimit
721721
}
722-
if err := models.UpdateRepository(repo, visibilityChanged); err != nil {
722+
723723
if err := repo_service.UpdateRepository(repo, visibilityChanged); err != nil {
724724
ctx.Error(http.StatusInternalServerError, "UpdateRepository", err)
725725
return err

routers/private/hook_pre_receive.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ func HookPreReceive(ctx *gitea_context.PrivateContext) {
114114
opts: opts,
115115
}
116116

117-
pushSize, err := git.CountObjectsWithEnv(repo.RepoPath(), env)
117+
repo := ourCtx.Repo.Repository
118+
119+
pushSize, err := git.CountObjectsWithEnv(ctx, repo.RepoPath(), ourCtx.env)
118120
if err != nil {
119-
log.Error("Unable to get repository size with env %v: %s Error: %v", repo.RepoPath(), env, err)
121+
log.Error("Unable to get repository size with env %v: %s Error: %v", repo.RepoPath(), ourCtx.env, err)
120122
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
121123
"err": err.Error(),
122124
})

routers/web/repo/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func SettingsPost(ctx *context.Context) {
192192
return
193193
}
194194

195-
if !ctx.User.IsAdmin && repo.SizeLimit != form.RepoSizeLimit {
195+
if !ctx.Doer.IsAdmin && repo.SizeLimit != form.RepoSizeLimit {
196196
ctx.Data["Err_RepoSizeLimit"] = true
197197
ctx.RenderWithErr(ctx.Tr("repo.form.repo_size_limit_only_by_admins"), tplSettingsOptions, &form)
198198
return

templates/repo/settings/options.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
</div>
1919
<div class="inline field">
2020
<label>{{.i18n.Tr "repo.repo_size"}}</label>
21-
<span {{if .Err_RepoSize}}class="ui text red"{{end}}>{{SizeFmt .Repository.Size}}{{if .Repository.SizeLimit}}/{{SizeFmt .Repository.SizeLimit}}{{end}}</span>
21+
<span {{if .Err_RepoSize}}class="ui text red"{{end}}>{{FileSize .Repository.Size}}{{if .Repository.SizeLimit}}/{{FileSize .Repository.SizeLimit}}{{end}}</span>
2222
</div>
2323
<div class="field {{if .Err_RepoSizeLimit}}error{{end}}" {{if not .IsAdmin}}style="display:none;"{{end}}>
24-
<label for="repo_size_limit">{{.i18n.Tr "repo.repo_size_limit"}}</label>
24+
<label for="repo_size_limit">{{.locale.Tr "repo.repo_size_limit"}}</label>
2525
<input id="repo_size_limit" name="repo_size_limit" type="number" value="{{.Repository.SizeLimit}}" data-repo-size-limit="{{.Repository.SizeLimit}}">
2626
<label>{{.locale.Tr "repo.repo_size"}}</label>
2727
<span>{{FileSize .Repository.Size}}</span>

0 commit comments

Comments
 (0)