Refactored according to suggestions

tokarchuk/v1.17
Martin Hartkorn 9 years ago
parent 15394f613f
commit 15d37b7a95
  1. 14
      conf/locale/locale_en-US.ini
  2. 4
      models/repo.go
  3. 12
      modules/auth/repo_form.go
  4. 5
      routers/repo/setting.go
  5. 2
      templates/repo/settings/options.tmpl

@ -584,19 +584,19 @@ settings.tracker_url_format = External Issue Tracker URL Format
settings.tracker_url_format_desc = You can use placeholder <code>{user} {repo} {index}</code> for user name, repository name and issue index. settings.tracker_url_format_desc = You can use placeholder <code>{user} {repo} {index}</code> for user name, repository name and issue index.
settings.pulls_desc = Enable pull requests to accept public contributions settings.pulls_desc = Enable pull requests to accept public contributions
settings.danger_zone = Danger Zone settings.danger_zone = Danger Zone
settings.transfer = Transfer Ownership
settings.transfer_desc = Transfer this repository to another user or to an organization in which you have admin rights.
settings.new_owner_has_same_repo = The new owner already has a repository with same name. Please choose another name. settings.new_owner_has_same_repo = The new owner already has a repository with same name. Please choose another name.
settings.convert = Convert To Regular Repository settings.convert = Convert To Regular Repository
settings.convert_desc = You can convert this mirror to a regular repository. This cannot be reversed. settings.convert_desc = You can convert this mirror to a regular repository. This cannot be reversed.
settings.delete = Delete This Repository
settings.delete_desc = Once you delete a repository, there is no going back. Please be certain.
settings.transfer_notices_1 = - You will lose access if new owner is a individual user.
settings.transfer_notices_2 = - You will conserve access if new owner is an organization and if you're one of the owners.
settings.transfer_form_title = Please enter following information to confirm your operation:
settings.convert_notices_1 = - This operation will convert this repository mirror into a regular repository and cannot be undone. settings.convert_notices_1 = - This operation will convert this repository mirror into a regular repository and cannot be undone.
settings.convert_succeed = Repository successfully converted. settings.convert_succeed = Repository successfully converted.
settings.convert_failed = Unable to convert repository. settings.convert_failed = Unable to convert repository.
settings.transfer = Transfer Ownership
settings.transfer_desc = Transfer this repository to another user or to an organization in which you have admin rights.
settings.transfer_notices_1 = - You will lose access if new owner is a individual user.
settings.transfer_notices_2 = - You will conserve access if new owner is an organization and if you're one of the owners.
settings.transfer_form_title = Please enter following information to confirm your operation:
settings.delete = Delete This Repository
settings.delete_desc = Once you delete a repository, there is no going back. Please be certain.
settings.delete_notices_1 = - This operation <strong>CANNOT</strong> be undone. settings.delete_notices_1 = - This operation <strong>CANNOT</strong> be undone.
settings.delete_notices_2 = - This operation will permanently delete the everything of this repository, including Git data, issues, comments and accesses of collaborators. settings.delete_notices_2 = - This operation will permanently delete the everything of this repository, including Git data, issues, comments and accesses of collaborators.
settings.delete_notices_fork_1 = - If this repository is public, all forks will become independent after deletion. settings.delete_notices_fork_1 = - If this repository is public, all forks will become independent after deletion.

@ -654,7 +654,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
return repo, UpdateRepository(repo, false) return repo, UpdateRepository(repo, false)
} }
repo, err = FinishMigrateRepository(repo, repoPath) repo, err = CleanUpMigrateInfo(repo, repoPath)
if err != nil { if err != nil {
return repo, err return repo, err
} }
@ -663,7 +663,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
} }
// Finish migrating repository with things that don't need to be done for mirrors. // Finish migrating repository with things that don't need to be done for mirrors.
func FinishMigrateRepository(repo *Repository, repoPath string) (*Repository, error) { func CleanUpMigrateInfo(repo *Repository, repoPath string) (*Repository, error) {
if err := createUpdateHook(repoPath); err != nil { if err := createUpdateHook(repoPath); err != nil {
return repo, fmt.Errorf("createUpdateHook: %v", err) return repo, fmt.Errorf("createUpdateHook: %v", err)
} }

@ -37,18 +37,6 @@ func (f *CreateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) bin
return validate(errs, ctx.Data, f, ctx.Locale) return validate(errs, ctx.Data, f, ctx.Locale)
} }
type ConvertRepoForm struct {
Uid int64 `binding:"Required"`
RepoId int64 `binding:"Required"`
RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
Private bool
Description string `binding:"MaxSize(255)"`
}
func (f *ConvertRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
return validate(errs, ctx.Data, f, ctx.Locale)
}
type MigrateRepoForm struct { type MigrateRepoForm struct {
CloneAddr string `json:"clone_addr" binding:"Required"` CloneAddr string `json:"clone_addr" binding:"Required"`
AuthUsername string `json:"auth_username"` AuthUsername string `json:"auth_username"`

@ -158,10 +158,9 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
ctx.Error(404) ctx.Error(404)
return return
} }
repo.IsMirror = false repo.IsMirror = false
if _, err := models.FinishMigrateRepository(repo, models.RepoPath(ctx.Repo.Owner.Name, repo.Name)); err != nil { if _, err := models.CleanUpMigrateInfo(repo, models.RepoPath(ctx.Repo.Owner.Name, repo.Name)); err != nil {
ctx.RenderWithErr(ctx.Tr("settings.convert.failed"), SETTINGS_OPTIONS, &form) ctx.RenderWithErr(ctx.Tr("settings.convert.failed"), SETTINGS_OPTIONS, &form)
return return
} }
@ -170,7 +169,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
ctx.RenderWithErr(ctx.Tr("settings.convert.failed"), SETTINGS_OPTIONS, &form) ctx.RenderWithErr(ctx.Tr("settings.convert.failed"), SETTINGS_OPTIONS, &form)
return return
} }
log.Trace("Repository converted: %s/%s", ctx.Repo.Owner.Name, repo.Name) log.Trace("Repository converted from mirror to regular: %s/%s", ctx.Repo.Owner.Name, repo.Name)
ctx.Flash.Success(ctx.Tr("repo.settings.convert_succeed")) ctx.Flash.Success(ctx.Tr("repo.settings.convert_succeed"))
ctx.Redirect(setting.AppSubUrl + "/" + ctx.Repo.Owner.Name + "/" + repo.Name) ctx.Redirect(setting.AppSubUrl + "/" + ctx.Repo.Owner.Name + "/" + repo.Name)

@ -178,6 +178,7 @@
</div> </div>
</div> </div>
{{if .Repository.IsMirror}}
<div class="ui small modal" id="convert-repo-modal"> <div class="ui small modal" id="convert-repo-modal">
<div class="header"> <div class="header">
{{.i18n.Tr "repo.settings.convert"}} {{.i18n.Tr "repo.settings.convert"}}
@ -207,6 +208,7 @@
</form> </form>
</div> </div>
</div> </div>
{{end}}
<div class="ui small modal" id="transfer-repo-modal"> <div class="ui small modal" id="transfer-repo-modal">
<div class="header"> <div class="header">

Loading…
Cancel
Save