(ctx context.Context, ch *cmdutil.Helper)
| 62 | } |
| 63 | |
| 64 | func (o *DeployOpts) ValidateAndApplyDefaults(ctx context.Context, ch *cmdutil.Helper) error { |
| 65 | if o.remoteURL != "" { |
| 66 | // already validated |
| 67 | // just a hack to avoid re-validation when `rill project deploy` internally calls `rill project connect-github` |
| 68 | return nil |
| 69 | } |
| 70 | // expand project directory and get absolute path |
| 71 | var err error |
| 72 | o.GitPath, err = fileutil.ExpandHome(o.GitPath) |
| 73 | if err != nil { |
| 74 | return err |
| 75 | } |
| 76 | o.GitPath, err = filepath.Abs(o.GitPath) |
| 77 | if err != nil { |
| 78 | return err |
| 79 | } |
| 80 | |
| 81 | _, _, err = ValidateLocalProject(ch, o.GitPath, o.SubPath) |
| 82 | if err != nil { |
| 83 | return err |
| 84 | } |
| 85 | |
| 86 | // check if specified project already exists |
| 87 | if o.Name != "" && ch.Org != "" { |
| 88 | p, exists, err := getProject(ctx, ch, ch.Org, o.Name) |
| 89 | if err != nil { |
| 90 | return err |
| 91 | } |
| 92 | if exists { |
| 93 | if ch.Interactive { |
| 94 | if err := cmdutil.ConfirmPrompt(fmt.Sprintf("Project with name %q already exists. Do you want to push current changes to the existing project?", o.Name), true); err != nil { |
| 95 | return err |
| 96 | } |
| 97 | } |
| 98 | o.pushToProject = p |
| 99 | o.Managed = o.pushToProject.ManagedGitId != "" |
| 100 | o.Github = o.pushToProject.ManagedGitId == "" && o.pushToProject.GitRemote != "" |
| 101 | o.ArchiveUpload = o.pushToProject.ArchiveAssetId != "" |
| 102 | return nil |
| 103 | } |
| 104 | } |
| 105 | if o.ArchiveUpload { |
| 106 | return nil |
| 107 | } |
| 108 | |
| 109 | // detect repo root and subpath |
| 110 | var repoRoot, subpath string |
| 111 | if o.SubPath != "" { |
| 112 | repoRoot = o.GitPath |
| 113 | subpath = o.SubPath |
| 114 | } else { |
| 115 | // detect subpath |
| 116 | repoRoot, subpath, err = gitutil.InferRepoRootAndSubpath(o.GitPath) |
| 117 | if err != nil { |
| 118 | // Not a git repository |
| 119 | return nil |
| 120 | } |
| 121 | } |
no test coverage detected