|
25 | 25 | subcmdCreateUser,
|
26 | 26 | subcmdChangePassword,
|
27 | 27 | subcmdRepoSyncReleases,
|
| 28 | + subcmdRegenerate, |
28 | 29 | },
|
29 | 30 | }
|
30 | 31 |
|
|
80 | 81 | Usage: "Synchronize repository releases with tags",
|
81 | 82 | Action: runRepoSyncReleases,
|
82 | 83 | }
|
| 84 | + |
| 85 | + subcmdRegenerate = cli.Command{ |
| 86 | + Name: "regenerate", |
| 87 | + Usage: "Regenerate specific files", |
| 88 | + Subcommands: []cli.Command{ |
| 89 | + microcmdRegenHooks, |
| 90 | + microcmdRegenKeys, |
| 91 | + }, |
| 92 | + } |
| 93 | + |
| 94 | + microcmdRegenHooks = cli.Command{ |
| 95 | + Name: "hooks", |
| 96 | + Usage: "Regenerate git-hooks", |
| 97 | + Action: runRegenerateHooks, |
| 98 | + Flags: []cli.Flag{ |
| 99 | + cli.StringFlag{ |
| 100 | + Name: "config, c", |
| 101 | + Value: "custom/conf/app.ini", |
| 102 | + Usage: "Custom configuration file path", |
| 103 | + }, |
| 104 | + }, |
| 105 | + } |
| 106 | + |
| 107 | + microcmdRegenKeys = cli.Command{ |
| 108 | + Name: "keys", |
| 109 | + Usage: "Regenerate authorized_keys file", |
| 110 | + Action: runRegenerateKeys, |
| 111 | + Flags: []cli.Flag{ |
| 112 | + cli.StringFlag{ |
| 113 | + Name: "config, c", |
| 114 | + Value: "custom/conf/app.ini", |
| 115 | + Usage: "Custom configuration file path", |
| 116 | + }, |
| 117 | + }, |
| 118 | + } |
83 | 119 | )
|
84 | 120 |
|
85 | 121 | func runChangePassword(c *cli.Context) error {
|
@@ -195,3 +231,25 @@ func getReleaseCount(id int64) (int64, error) {
|
195 | 231 | },
|
196 | 232 | )
|
197 | 233 | }
|
| 234 | + |
| 235 | +func runRegenerateHooks(c *cli.Context) error { |
| 236 | + if c.IsSet("config") { |
| 237 | + setting.CustomConf = c.String("config") |
| 238 | + } |
| 239 | + |
| 240 | + if err := initDB(); err != nil { |
| 241 | + return err |
| 242 | + } |
| 243 | + return models.SyncRepositoryHooks() |
| 244 | +} |
| 245 | + |
| 246 | +func runRegenerateKeys(c *cli.Context) error { |
| 247 | + if c.IsSet("config") { |
| 248 | + setting.CustomConf = c.String("config") |
| 249 | + } |
| 250 | + |
| 251 | + if err := initDB(); err != nil { |
| 252 | + return err |
| 253 | + } |
| 254 | + return models.RewriteAllPublicKeys() |
| 255 | +} |
0 commit comments