mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Add repo mirror and import
This commit is contained in:
		| @@ -130,7 +130,9 @@ func validate(errors *binding.Errors, data base.TmplData, form Form) { | ||||
| 			case binding.MaxSizeError: | ||||
| 				data["ErrorMsg"] = form.Name(field.Name) + " must contain at most " + getMinMaxSize(field) + " characters" | ||||
| 			case binding.EmailError: | ||||
| 				data["ErrorMsg"] = form.Name(field.Name) + " is not valid" | ||||
| 				data["ErrorMsg"] = form.Name(field.Name) + " is not a valid e-mail address" | ||||
| 			case binding.UrlError: | ||||
| 				data["ErrorMsg"] = form.Name(field.Name) + " is not a valid URL" | ||||
| 			default: | ||||
| 				data["ErrorMsg"] = "Unknown error: " + err | ||||
| 			} | ||||
|   | ||||
| @@ -18,11 +18,11 @@ import ( | ||||
|  | ||||
| type CreateRepoForm struct { | ||||
| 	RepoName    string `form:"repo" binding:"Required;AlphaDash"` | ||||
| 	Private     string `form:"private"` | ||||
| 	Private     bool   `form:"private"` | ||||
| 	Description string `form:"desc" binding:"MaxSize(100)"` | ||||
| 	Language    string `form:"language"` | ||||
| 	License     string `form:"license"` | ||||
| 	InitReadme  string `form:"initReadme"` | ||||
| 	InitReadme  bool   `form:"initReadme"` | ||||
| } | ||||
|  | ||||
| func (f *CreateRepoForm) Name(field string) string { | ||||
| @@ -51,3 +51,41 @@ func (f *CreateRepoForm) Validate(errors *binding.Errors, req *http.Request, con | ||||
|  | ||||
| 	validate(errors, data, f) | ||||
| } | ||||
|  | ||||
| type MigrateRepoForm struct { | ||||
| 	Url          string `form:"url" binding:"Url"` | ||||
| 	AuthUserName string `form:"auth_username"` | ||||
| 	AuthPasswd   string `form:"auth_password"` | ||||
| 	RepoName     string `form:"repo" binding:"Required;AlphaDash"` | ||||
| 	Mirror       bool   `form:"mirror"` | ||||
| 	Private      bool   `form:"private"` | ||||
| 	Description  string `form:"desc" binding:"MaxSize(100)"` | ||||
| } | ||||
|  | ||||
| func (f *MigrateRepoForm) Name(field string) string { | ||||
| 	names := map[string]string{ | ||||
| 		"Url":         "Migration URL", | ||||
| 		"RepoName":    "Repository name", | ||||
| 		"Description": "Description", | ||||
| 	} | ||||
| 	return names[field] | ||||
| } | ||||
|  | ||||
| func (f *MigrateRepoForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) { | ||||
| 	if req.Method == "GET" || errors.Count() == 0 { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData) | ||||
| 	data["HasError"] = true | ||||
| 	AssignForm(f, data) | ||||
|  | ||||
| 	if len(errors.Overall) > 0 { | ||||
| 		for _, err := range errors.Overall { | ||||
| 			log.Error("MigrateRepoForm.Validate: %v", err) | ||||
| 		} | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	validate(errors, data, f) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user