示例#1
0
文件: delete.go 项目: hawx/ggg
func Delete(db repos.Db) http.Handler {
	return mux.Method{
		"GET": http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			repoName := route.Vars(r)["name"]

			repo := db.Get(repoName)
			db.Delete(repo)
			os.RemoveAll(repo.Path)

			http.Redirect(w, r, "/", 302)
		}),
	}
}
示例#2
0
文件: github.go 项目: hawx/ggg
func copyRepo(db repos.Db, repo github.Repository) {
	if db.Get(*repo.Name).Name != "" {
		log.Println("skipping", *repo.Name)
		return
	}

	homepage := ""
	if repo.Homepage != nil {
		homepage = *repo.Homepage
	}

	description := ""
	if repo.Description != nil {
		description = *repo.Description
	}

	private := false
	if repo.Private != nil {
		private = *repo.Private
	}

	branch := ""
	if repo.DefaultBranch != nil {
		branch = *repo.DefaultBranch
	}

	db.Create(
		*repo.Name,
		homepage,
		description,
		branch,
		private)

	created := db.Get(*repo.Name)

	git.CopyRepo(created.Path, *repo.CloneURL)
	log.Println("copied", *repo.Name)
}