#19 add reset
This commit is contained in:
parent
fd3315b12b
commit
6edef692a0
@ -467,13 +467,6 @@ func (g Gitea) fetchCheckout(ctx context.Context, repo *git.Repository, branch,
|
|||||||
|
|
||||||
var headRef *plumbing.Reference
|
var headRef *plumbing.Reference
|
||||||
|
|
||||||
targetBranch, err := repo.Branch(plumbing.NewBranchReferenceName(branch).String())
|
|
||||||
if err != nil {
|
|
||||||
g.logger.Error(ctx, "cant get repo branch", err)
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
g.logger.Info(ctx, "targetBranch: ", targetBranch)
|
|
||||||
|
|
||||||
branches, err := repo.Branches()
|
branches, err := repo.Branches()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.logger.Error(ctx, "cant get repo branch", err)
|
g.logger.Error(ctx, "cant get repo branch", err)
|
||||||
@ -500,12 +493,6 @@ func (g Gitea) fetchCheckout(ctx context.Context, repo *git.Repository, branch,
|
|||||||
|
|
||||||
g.logger.Info(ctx, "repo head "+headRef.String())
|
g.logger.Info(ctx, "repo head "+headRef.String())
|
||||||
|
|
||||||
rev, err := repo.ResolveRevision(plumbing.Revision(fmt.Sprintf("remotes/%s/%s", targetBranch.Remote, headRef.Name().Short())))
|
|
||||||
if err != nil {
|
|
||||||
g.logger.Error(ctx, "resolve revision error: ", err)
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
wtree, err := repo.Worktree()
|
wtree, err := repo.Worktree()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.logger.Error(ctx, "failed to get worktree", err)
|
g.logger.Error(ctx, "failed to get worktree", err)
|
||||||
@ -513,8 +500,7 @@ func (g Gitea) fetchCheckout(ctx context.Context, repo *git.Repository, branch,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err = wtree.Reset(&git.ResetOptions{
|
if err = wtree.Reset(&git.ResetOptions{
|
||||||
Commit: *rev,
|
Mode: git.HardReset,
|
||||||
Mode: git.HardReset,
|
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
g.logger.Error(ctx, "reset work_tree error: ", err)
|
g.logger.Error(ctx, "reset work_tree error: ", err)
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user