Exemplo n.º 1
0
Arquivo: delete.go Projeto: 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)
		}),
	}
}
Exemplo n.º 2
0
Arquivo: github.go Projeto: 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)
}