| 45 | import org.eclipse.jgit.lib.Repository; |
| 46 | |
| 47 | @Singleton |
| 48 | public class InitLabels implements InitStep { |
| 49 | private static final String KEY_LABEL = "label"; |
| 50 | |
| 51 | private final ConsoleUI ui; |
| 52 | private final AllProjectsConfig allProjectsConfig; |
| 53 | private final AllProjectsNameOnInitProvider allProjectsName; |
| 54 | private PersonIdent serverUser; |
| 55 | private ProjectConfig.Factory projectConfigFactory; |
| 56 | private SystemGroupBackend systemGroupBackend; |
| 57 | |
| 58 | private boolean installVerified; |
| 59 | |
| 60 | @Inject |
| 61 | InitLabels( |
| 62 | ConsoleUI ui, |
| 63 | AllProjectsConfig allProjectsConfig, |
| 64 | AllProjectsNameOnInitProvider allProjectsName) { |
| 65 | this.ui = ui; |
| 66 | this.allProjectsConfig = allProjectsConfig; |
| 67 | this.allProjectsName = allProjectsName; |
| 68 | } |
| 69 | |
| 70 | @Inject(optional = true) |
| 71 | void setProjectConfigFactory(ProjectConfig.Factory projectConfigFactory) { |
| 72 | this.projectConfigFactory = projectConfigFactory; |
| 73 | } |
| 74 | |
| 75 | @Inject(optional = true) |
| 76 | void setGerritPersonIdent(@GerritPersonIdent PersonIdent serverUser) { |
| 77 | this.serverUser = serverUser; |
| 78 | } |
| 79 | |
| 80 | @Inject(optional = true) |
| 81 | void setSystemGroupBackend(SystemGroupBackend systemGroupBackend) { |
| 82 | this.systemGroupBackend = systemGroupBackend; |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public void run() throws Exception { |
| 87 | Config cfg = allProjectsConfig.load().getConfig(); |
| 88 | if (cfg == null || !cfg.getSubsections(KEY_LABEL).contains(VERIFIED)) { |
| 89 | ui.header("Review Labels"); |
| 90 | installVerified = ui.yesno(false, "Install Verified label"); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | @Override |
| 95 | public void postRun() throws Exception { |
| 96 | if (installVerified) { |
| 97 | installVerified(); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | private void installVerified() throws IOException, ConfigInvalidException { |
| 102 | try (Repository git = allProjectsConfig.openGitRepository(); |
| 103 | MetaDataUpdate md = |
| 104 | new MetaDataUpdate( |
nothing calls this directly
no outgoing calls
no test coverage detected