Skip to content

Commit 2d1657b

Browse files
author
Vladimir Kotal
committed
construct Project with Configuration
fixes #2151
1 parent 1b33dd2 commit 2d1657b

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/org/opensolaris/opengrok/configuration/messages/ProjectMessage.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ protected byte[] applyMessage(RuntimeEnvironment env) throws Exception {
115115
File projDir = new File(srcRoot, projectName);
116116

117117
if (!env.getProjects().containsKey(projectName)) {
118-
Project project = new Project(projectName, "/" + projectName);
119-
project.setTabSize(env.getConfiguration().getTabSize());
118+
Project project = new Project(projectName, "/" + projectName, env.getConfiguration());
120119

121120
// Add repositories in this project.
122121
List<RepositoryInfo> repos = getRepositoriesInDir(env, projDir);

test/org/opensolaris/opengrok/configuration/messages/ProjectMessageTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public void setUp() throws IOException {
8787
env.setDataRoot(repository.getDataRoot());
8888
env.setProjectsEnabled(true);
8989
env.setHistoryEnabled(true);
90+
env.setHandleHistoryOfRenamedFiles(true);
9091
RepositoryFactory.initializeIgnoredNames(env);
9192
}
9293

@@ -143,6 +144,34 @@ public void testValidate() {
143144
}
144145
}
145146

147+
/**
148+
* Verify that project added via Message correctly inherits a property
149+
* from configuration. Ideally, this should test all properties of Project.
150+
* @throws Exception
151+
*/
152+
@ConditionalRun(RepositoryInstalled.GitInstalled.class)
153+
@Test
154+
public void testAddInherit() throws Exception {
155+
Assert.assertTrue(env.getRepositories().isEmpty());
156+
Assert.assertTrue(env.getProjects().isEmpty());
157+
Assert.assertTrue(env.isHandleHistoryOfRenamedFiles());
158+
159+
// Prepare project addition.
160+
Message m = new ProjectMessage();
161+
m.setText("add");
162+
m.addTag("git");
163+
164+
// Add the project.
165+
m.apply(env);
166+
167+
Assert.assertTrue(env.getProjects().containsKey("git"));
168+
Assert.assertEquals(1, env.getProjects().size());
169+
170+
Project proj = env.getProjects().get("git");
171+
Assert.assertNotNull(proj);
172+
Assert.assertTrue(proj.isHandleRenamedFiles());
173+
}
174+
146175
@Test
147176
public void testAdd() throws Exception {
148177
Assert.assertTrue(env.getRepositories().isEmpty());

0 commit comments

Comments
 (0)