@@ -287,12 +287,22 @@ func checkout(trashDir string, i conf.Import) {
287287 }
288288 logrus .Infof ("Checking out '%s', commit: '%s'" , i .Package , i .Version )
289289 version := i .Version
290- if isBranch (remoteName (i .Repo ), i .Version ) {
290+ if i . Version == "master" || isBranch (remoteName (i .Repo ), i .Version ) {
291291 version = remoteName (i .Repo ) + "/" + i .Version
292+ if err := fetch (i ); err != nil {
293+ logrus .WithFields (logrus.Fields {"i" : i }).Fatalf ("fetch failed" )
294+ }
292295 }
293296 if bytes , err := exec .Command ("git" , "checkout" , "-f" , "--detach" , version ).CombinedOutput (); err != nil {
294297 logrus .Debugf ("Error running `git checkout -f --detach %s`:\n %s" , version , bytes )
295- if err := fetch (i ); err != nil {
298+ if i .Version == "master" {
299+ logrus .Warn ("Failed to checkout 'master' branch: checking out the latest commit git can find" )
300+ bytes , err := exec .Command ("git" , "log" , "--all" , "--pretty=oneline" , "--abbrev-commit" , "-1" ).Output ()
301+ if err != nil {
302+ logrus .Fatalf ("Failed to get latest commit with `git log --all --pretty=oneline --abbrev-commit -1`: %s" , err )
303+ }
304+ version = strings .Fields (strings .TrimSpace (string (bytes )))[0 ]
305+ } else if err := fetch (i ); err != nil {
296306 logrus .WithFields (logrus.Fields {"i" : i }).Fatalf ("fetch failed" )
297307 }
298308 logrus .Debugf ("Retrying!: `git checkout -f --detach %s`" , version )
0 commit comments