// Copyright 2015 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""path/filepath""strings")typeArchiveTypeintconst(ZIPArchiveType=iota+1TARGZ)func(c*Commit)CreateArchive(targetstring,archiveTypeArchiveType)error{varformatstringswitcharchiveType{caseZIP:format="zip"caseTARGZ:format="tar.gz"default:returnfmt.Errorf("unknown format: %v",archiveType)}_,err:=NewCommand("archive","--prefix="+filepath.Base(strings.TrimSuffix(c.repo.Path,".git"))+"/","--format="+format,"-o",target,c.ID.String()).RunInDir(c.repo.Path)returnerr}