// Copyright 2014 The Gogs Authors. All rights reserved.// Use of this source code is governed by a MIT-style// license that can be found in the LICENSE file.packagegitimport("fmt""github.com/Unknwon/com")typeArchiveTypeintconst(ZIPArchiveType=iota+1TARGZ)func(c*Commit)CreateArchive(pathstring,archiveTypeArchiveType)error{varformatstringswitcharchiveType{caseZIP:format="zip"caseTARGZ:format="tar.gz"default:returnfmt.Errorf("unknown format: %v",archiveType)}_,stderr,err:=com.ExecCmdDir(c.repo.Path,"git","archive","--format="+format,"-o",path,c.Id.String())iferr!=nil{returnfmt.Errorf("%s",stderr)}returnnil}