@@ -120,13 +120,16 @@ func LFSLocks(ctx *context.Context) {
120120 }); err != nil {
121121 log .Error ("Failed to clone repository: %s (%v)" , ctx .Repo .Repository .FullName (), err )
122122 ctx .ServerError ("LFSLocks" , fmt .Errorf ("Failed to clone repository: %s (%v)" , ctx .Repo .Repository .FullName (), err ))
123+ return
123124 }
124125
125126 gitRepo , err := git .OpenRepository (tmpBasePath )
126127 if err != nil {
127128 log .Error ("Unable to open temporary repository: %s (%v)" , tmpBasePath , err )
128129 ctx .ServerError ("LFSLocks" , fmt .Errorf ("Failed to open new temporary repository in: %s %v" , tmpBasePath , err ))
130+ return
129131 }
132+ defer gitRepo .Close ()
130133
131134 filenames := make ([]string , len (lfsLocks ))
132135
@@ -137,6 +140,7 @@ func LFSLocks(ctx *context.Context) {
137140 if err := gitRepo .ReadTreeToIndex (ctx .Repo .Repository .DefaultBranch ); err != nil {
138141 log .Error ("Unable to read the default branch to the index: %s (%v)" , ctx .Repo .Repository .DefaultBranch , err )
139142 ctx .ServerError ("LFSLocks" , fmt .Errorf ("Unable to read the default branch to the index: %s (%v)" , ctx .Repo .Repository .DefaultBranch , err ))
143+ return
140144 }
141145
142146 name2attribute2info , err := gitRepo .CheckAttribute (git.CheckAttributeOpts {
@@ -147,6 +151,7 @@ func LFSLocks(ctx *context.Context) {
147151 if err != nil {
148152 log .Error ("Unable to check attributes in %s (%v)" , tmpBasePath , err )
149153 ctx .ServerError ("LFSLocks" , err )
154+ return
150155 }
151156
152157 lockables := make ([]bool , len (lfsLocks ))
@@ -166,6 +171,7 @@ func LFSLocks(ctx *context.Context) {
166171 if err != nil {
167172 log .Error ("Unable to lsfiles in %s (%v)" , tmpBasePath , err )
168173 ctx .ServerError ("LFSLocks" , err )
174+ return
169175 }
170176
171177 filemap := make (map [string ]bool , len (filelist ))
0 commit comments