@@ -14,58 +14,49 @@ func (s *Service) processCheckout(ctx context.Context, op *sdk.Operation) error
1414 }
1515
1616 if err := gitRepo .ResetHard ("origin/" + currentBranch ); err != nil {
17- log .Error (ctx , "Repositories> processCheckout> ResetHard> [%s] Error: %v" , op .UUID , err )
18- return err
17+ return sdk .WithStack (err )
1918 }
2019
2120 if op .Setup .Checkout .Tag != "" {
22- log .Debug ("Repositories> processCheckout> fetching tag %s from %s" , op .Setup .Checkout .Tag , op .URL )
21+ log .Debug ("processCheckout> fetching tag %s from %s" , op .Setup .Checkout .Tag , op .URL )
2322 if err := gitRepo .FetchRemoteTag ("origin" , op .Setup .Checkout .Tag ); err != nil {
24- log .Error (ctx , "Repositories> processCheckout> FetchRemoteTag> [%s] error %v" , op .UUID , err )
25- return err
23+ return sdk .WithStack (err )
2624 }
2725 } else {
2826 if op .Setup .Checkout .Branch == "" {
2927 op .Setup .Checkout .Branch = op .RepositoryInfo .DefaultBranch
3028 }
31-
32- log .Debug ("Repositories> processCheckout> fetching branch %s from %s" , op .Setup .Checkout .Branch , op .URL )
29+ log .Debug ("processCheckout> fetching branch %s from %s" , op .Setup .Checkout .Branch , op .URL )
3330 if err := gitRepo .FetchRemoteBranch ("origin" , op .Setup .Checkout .Branch ); err != nil {
34- log .Error (ctx , "Repositories> processCheckout> FetchRemoteBranch> [%s] error %v" , op .UUID , err )
35- return err
31+ return sdk .WithStack (err )
3632 }
3733 }
3834
39- //Check commit
35+ // Check commit
4036 if op .Setup .Checkout .Commit == "" {
41- log .Debug ("Repositories> processCheckout> pulling branch %s" , op .Setup .Checkout .Branch )
37+ log .Debug ("processCheckout> pulling branch %s" , op .Setup .Checkout .Branch )
4238 if err := gitRepo .Pull ("origin" , op .Setup .Checkout .Branch ); err != nil {
43- log .Error (ctx , "Repositories> processCheckout> Pull without commit> [%s] error %v" , op .UUID , err )
44- return err
39+ return sdk .WithStack (err )
4540 }
4641 } else {
4742 currentCommit , err := gitRepo .LatestCommit ()
4843 if err != nil {
49- log .Error (ctx , "Repositories> processCheckout> LatestCommit> [%s] error %v" , op .UUID , err )
50- return err
44+ return sdk .WithStack (err )
5145 }
5246 if currentCommit .LongHash != op .Setup .Checkout .Commit {
53- //Not the same commit
54- //Pull and reset HARD the commit
55- log .Debug ("Repositories> processCheckout> resetting the branch %s from remote" , op .Setup .Checkout .Branch )
47+ // Not the same commit, pull and reset HARD the commit
48+ log .Debug ("processCheckout> resetting the branch %s from remote" , op .Setup .Checkout .Branch )
5649 if err := gitRepo .ResetHard ("origin/" + op .Setup .Checkout .Branch ); err != nil {
57- log .Error (ctx , "Repositories> processCheckout> ResetHard> [%s] error %v" , op .UUID , err )
58- return err
50+ return sdk .WithStack (err )
5951 }
6052
6153 log .Debug ("Repositories> processCheckout> reseting commit %s" , op .Setup .Checkout .Commit )
6254 if err := gitRepo .ResetHard (op .Setup .Checkout .Commit ); err != nil {
63- log .Error (ctx , "Repositories> processCheckout> ResetHard> [%s] error %v" , op .UUID , err )
64- return err
55+ return sdk .WithStack (err )
6556 }
6657 }
6758 }
6859
69- log .Info (ctx , "Repositories> processCheckout> repository %s ready" , op .URL )
60+ log .Info (ctx , "processCheckout> repository %s ready" , op .URL )
7061 return nil
7162}
0 commit comments