-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
+
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/global.jelly b/src/main/resources/hudson/plugins/repo/RepoScm/global.jelly
index a40ba8b..333a20c 100644
--- a/src/main/resources/hudson/plugins/repo/RepoScm/global.jelly
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/global.jelly
@@ -1,3 +1,4 @@
+
+ checkUrl="${rootURL}/scm/RepoScm/executableCheck" checkDependsOn=""/>
\ No newline at end of file
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-cleanFirst.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-cleanFirst.html
new file mode 100644
index 0000000..a5683cb
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-cleanFirst.html
@@ -0,0 +1,5 @@
+
+
+ When this is checked the first thing to do will be a
repo forall -c "git clean -fdx"
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-currentBranch.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-currentBranch.html
new file mode 100644
index 0000000..e91bfca
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-currentBranch.html
@@ -0,0 +1,7 @@
+
+
+ Fetch only the current branch from server.
+ Increases the speed of the repo sync operation.
+ This is passed to repo as repo init --current-branch and repo sync -c.
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-depth.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-depth.html
new file mode 100644
index 0000000..1fed342
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-depth.html
@@ -0,0 +1,7 @@
+
+
+ Specify the depth in history to sync from the source. The default is to sync all of the history.
+ Use 1 to just sync the most recent commit.
+ This is passed to repo as repo init --depth=n.
+
+
diff --git a/src/main/webapp/help-destinationDir.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-destinationDir.html
similarity index 100%
rename from src/main/webapp/help-destinationDir.html
rename to src/main/resources/hudson/plugins/repo/RepoScm/help-destinationDir.html
diff --git a/src/main/webapp/help-executable.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-executable.html
similarity index 66%
rename from src/main/webapp/help-executable.html
rename to src/main/resources/hudson/plugins/repo/RepoScm/help-executable.html
index ca07b2f..36abadd 100644
--- a/src/main/webapp/help-executable.html
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-executable.html
@@ -1,10 +1,10 @@
This is the path to the repo executable which will be called whenever repo commands
- are ran. Repo can be installed by running curl https://android.git.kernel.org/repo > ~/bin/repo
+ are ran. Repo can be installed by running curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
See more documentation about installing
- and using repo.
+ and using repo.
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-fetchSubmodules.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-fetchSubmodules.html
new file mode 100644
index 0000000..6527f04
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-fetchSubmodules.html
@@ -0,0 +1,6 @@
+
+
+ Fetch submodules for from server.
+ This is passed to repo as repo sync --fetch-submodules.
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-forceSync.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-forceSync.html
new file mode 100644
index 0000000..0e91f52
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-forceSync.html
@@ -0,0 +1,7 @@
+
+
+ Overwrite an existing git directory if it needs to point to a different
+ object directory. WARNING: this may cause loss of data.
+ This is passed to repo as repo sync --force-sync.
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-gitLfs.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-gitLfs.html
new file mode 100644
index 0000000..f3e6aaa
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-gitLfs.html
@@ -0,0 +1,6 @@
+
+
+ Allow repositories utilizing LFS to sync LFS objects.
+ This is passed to repo as repo init --git-lfs.
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-ignoreChanges.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-ignoreChanges.html
new file mode 100644
index 0000000..f358ce9
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-ignoreChanges.html
@@ -0,0 +1,6 @@
+
+
+ Specify projects changes in which would not be considered a change that requires project rebuild when polling scm.
+ Project should be specified as the name in the name section of the project declaration in manifest separated by spaces.
+
+
diff --git a/src/main/webapp/help-jobs.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-jobs.html
similarity index 100%
rename from src/main/webapp/help-jobs.html
rename to src/main/resources/hudson/plugins/repo/RepoScm/help-jobs.html
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-localManifest.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-localManifest.html
new file mode 100644
index 0000000..a49b1af
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-localManifest.html
@@ -0,0 +1,19 @@
+
+
+ The contents of .repo/local_manifests/local.xml. This is written prior to
+calling sync. The default is to not use a local.xml file.
+
+
The contents may be given here literally, as XML; see the example below.
+Such literal content must start with the
+string <?xml. Alternatively, the content may be given
+as an URL, in which case the file pointed by the URL is used. If the
+content does not start with the <?xml prefix, it is
+assumed to be an URL.
+
An example
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <manifest>
+ <project path="external/project" name="org/project" remote="github" revision="master" />
+ </manifest>
+
+
diff --git a/src/main/webapp/help-manifestBranch.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestBranch.html
similarity index 100%
rename from src/main/webapp/help-manifestBranch.html
rename to src/main/resources/hudson/plugins/repo/RepoScm/help-manifestBranch.html
diff --git a/src/main/webapp/help-manifestFile.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestFile.html
similarity index 100%
rename from src/main/webapp/help-manifestFile.html
rename to src/main/resources/hudson/plugins/repo/RepoScm/help-manifestFile.html
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestGroup.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestGroup.html
new file mode 100644
index 0000000..35d366e
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestGroup.html
@@ -0,0 +1,7 @@
+
+
+ Restricts manifest projects to ones tagged with provided group name. This is passed to repo as
+ repo init -g groupName. If a group name is not provided, the -g
+ option is not passed to repo and it will default to fetching projects that are tagged with 'default'.
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestPlatform.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestPlatform.html
new file mode 100644
index 0000000..9b92243
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestPlatform.html
@@ -0,0 +1,8 @@
+
+
+ Restrict manifest projects to ones with a specified platform group [auto|all|none|linux|darwin|...]
+ This is passed to repo as repo init -P platformName. If a platform is not provided, the
+ -p option is not passed to repo and it will default to auto and ony fetch projects
+ which needed for current system.
+
+
diff --git a/src/main/webapp/help-manifestRepositoryUrl.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestRepositoryUrl.html
similarity index 100%
rename from src/main/webapp/help-manifestRepositoryUrl.html
rename to src/main/resources/hudson/plugins/repo/RepoScm/help-manifestRepositoryUrl.html
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestSubmodules.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestSubmodules.html
new file mode 100644
index 0000000..93cdf44
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-manifestSubmodules.html
@@ -0,0 +1,6 @@
+
+
+ Sync any submodules associated with the manifest repo.
+ This is passed to repo as repo init --submodules.
+
+
diff --git a/src/main/webapp/help-mirrorDir.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-mirrorDir.html
similarity index 100%
rename from src/main/webapp/help-mirrorDir.html
rename to src/main/resources/hudson/plugins/repo/RepoScm/help-mirrorDir.html
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-noCloneBundle.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-noCloneBundle.html
new file mode 100644
index 0000000..8f7cbba
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-noCloneBundle.html
@@ -0,0 +1,6 @@
+
+
+ When this is checked --no-clone-bundle is used when running
+ the repo init and repo sync commands.
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-noTags.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-noTags.html
new file mode 100644
index 0000000..a3f1604
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-noTags.html
@@ -0,0 +1,6 @@
+
+
+ Don't fetch tags.
+ This is passed to repo as repo init --no-tags and repo sync --no-tags.
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-quiet.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-quiet.html
new file mode 100644
index 0000000..097aa73
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-quiet.html
@@ -0,0 +1,6 @@
+
+
+ Make repo more quiet.
+ This is passed to repo as repo sync -q.
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-repoBranch.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-repoBranch.html
new file mode 100644
index 0000000..b2277b5
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-repoBranch.html
@@ -0,0 +1,6 @@
+
+
+ Use a specific branch for pulling repo itself. By default this is empty, and repo will be using its
+ default branch (i.e. stable)
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-repoUrl.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-repoUrl.html
new file mode 100644
index 0000000..20c90c9
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-repoUrl.html
@@ -0,0 +1,6 @@
+
+
+ Pull repo itself from this git repository. By default this is empty, and repo will be pulled
+ from its default git url (i.e. googles)
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-resetFirst.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-resetFirst.html
new file mode 100644
index 0000000..2443d42
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-resetFirst.html
@@ -0,0 +1,5 @@
+
+
+ When this is checked the first thing to do will be a
repo forall -c "git reset --hard"
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-showAllChanges.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-showAllChanges.html
new file mode 100644
index 0000000..18bcd6f
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-showAllChanges.html
@@ -0,0 +1,6 @@
+
+
+ When this is checked --first-parent is no longer passed
+ to git log when determining changesets.
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-trace.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-trace.html
new file mode 100644
index 0000000..04eb903
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-trace.html
@@ -0,0 +1,6 @@
+
+
+ Trace git command execution. This is passed to repo as
+ repo --trace <subcommand>.
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help-worktree.html b/src/main/resources/hudson/plugins/repo/RepoScm/help-worktree.html
new file mode 100644
index 0000000..f2464f3
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help-worktree.html
@@ -0,0 +1,5 @@
+
+
+ Use `git worktree` for checkouts (At least, Git version 2.15 is required to avoid dangerous gc bugs). Usefull under Windows because it no longer require symlinks at all.
+
+
diff --git a/src/main/resources/hudson/plugins/repo/RepoScm/help.html b/src/main/resources/hudson/plugins/repo/RepoScm/help.html
new file mode 100644
index 0000000..b84d890
--- /dev/null
+++ b/src/main/resources/hudson/plugins/repo/RepoScm/help.html
@@ -0,0 +1,11 @@
+
+
+ The repo plugin provides Repo as an SCM tools in Jenkins.
+
+
+
+ The repo plugin provides an SCM implementation to be used with the Pipeline SCM checkout step.
+ The Pipeline Syntax Snippet Generator guides the user to select repo plugin checkout options and provides online help for each of the options.
+
+
+
diff --git a/src/main/resources/hudson/plugins/repo/TagAction/badge.jelly b/src/main/resources/hudson/plugins/repo/TagAction/badge.jelly
deleted file mode 100644
index 1e0fcb2..0000000
--- a/src/main/resources/hudson/plugins/repo/TagAction/badge.jelly
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/hudson/plugins/repo/TagAction/tagForm.jelly b/src/main/resources/hudson/plugins/repo/TagAction/tagForm.jelly
deleted file mode 100644
index f701fee..0000000
--- a/src/main/resources/hudson/plugins/repo/TagAction/tagForm.jelly
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
- Repo Manifest - Build #${it.build.number}
- To recreate this build, copy the below manifest and past it to .repo/manifest.xml, then run 'repo sync'.
- When done, be sure to undo changes to the .repo/manifest.xml file and repo sync again.
-
- Manifest File:
-
-
-
-
\ No newline at end of file
diff --git a/src/main/resources/index.jelly b/src/main/resources/index.jelly
index c2561e6..b6a6189 100644
--- a/src/main/resources/index.jelly
+++ b/src/main/resources/index.jelly
@@ -1,4 +1,5 @@
+
- This plugin allows use of
repo as
- an SCM tool. A repo binary is required.
+ This plugin allows use of
Repo as
+ an SCM tool. A repo binary is required.
\ No newline at end of file
diff --git a/src/main/webapp/help-localManifest.html b/src/main/webapp/help-localManifest.html
deleted file mode 100644
index 1ce40a4..0000000
--- a/src/main/webapp/help-localManifest.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- The contents of .repo/local_manifest.xml. This is written prior to
-callinging sync. The default is to not use a local_manifest file.
-
-
diff --git a/src/test/java/hudson/plugins/repo/ManifestValidatorTest.java b/src/test/java/hudson/plugins/repo/ManifestValidatorTest.java
new file mode 100644
index 0000000..6dbd84a
--- /dev/null
+++ b/src/test/java/hudson/plugins/repo/ManifestValidatorTest.java
@@ -0,0 +1,56 @@
+package hudson.plugins.repo;
+
+import org.junit.Test;
+import org.jvnet.hudson.test.Issue;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.fail;
+
+public class ManifestValidatorTest {
+
+ @Issue("SECURITY-2478")
+ @Test
+ public void validateWhenFetchAttributeReferencesLocalPathThenAbort() {
+ String manifest = "\n" +
+ "\n" +
+ " \n" +
+ "\n" +
+ " \n" +
+ "";
+ try {
+ ManifestValidator.validate(manifest.getBytes(StandardCharsets.UTF_8), "repoUrl");
+ fail("should fail because fetch attribute in remote tag references a local path");
+ } catch (IOException e) {
+ assertThat(e.getMessage(), is("Checkout of Repo url 'repoUrl' aborted because manifest references a local directory, " +
+ "which may be insecure. You can allow local checkouts anyway by setting the system property '" +
+ RepoScm.ALLOW_LOCAL_CHECKOUT_PROPERTY + "' to true."));
+ }
+ }
+
+ @Issue("SECURITY-2478")
+ @Test
+ public void validateWhenValidManifestThenDoNotAbort() {
+ String manifest = "\n" +
+ "\n" +
+ " \n" +
+ "\n" +
+ " \n" +
+ " ";
+
+ try {
+ ManifestValidator.validate(manifest.getBytes(StandardCharsets.UTF_8), "repoUrl");
+ } catch (Exception e) {
+ fail("fail because input is valid and no exception expected");
+ }
+ }
+}
diff --git a/src/test/java/hudson/plugins/repo/RepoScmTest.java b/src/test/java/hudson/plugins/repo/RepoScmTest.java
new file mode 100644
index 0000000..88527aa
--- /dev/null
+++ b/src/test/java/hudson/plugins/repo/RepoScmTest.java
@@ -0,0 +1,34 @@
+package hudson.plugins.repo;
+
+import hudson.model.FreeStyleProject;
+import hudson.tasks.Shell;
+import org.junit.Rule;
+import org.junit.Test;
+import org.jvnet.hudson.test.JenkinsRule;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * {@link JenkinsRule} based tests for {@link RepoScm}
+ */
+public class RepoScmTest {
+ @Rule
+ public JenkinsRule j = new JenkinsRule();
+
+ @Test
+ public void configRoundTrip() throws Exception {
+ FreeStyleProject project = j.createFreeStyleProject();
+ final String manifestRepositoryUrl = "https://gerrit/projects/platform.git";
+ RepoScm scm = new RepoScm(manifestRepositoryUrl);
+ scm.setCleanFirst(true);
+ project.setScm(scm);
+ project.getBuildersList().add(new Shell("ecgo hello"));
+ project.save();
+ j.configRoundtrip(project);
+ project = j.jenkins.getItemByFullName(project.getFullName(), FreeStyleProject.class);
+ scm = (RepoScm) project.getScm();
+ assertTrue(scm.isCleanFirst());
+ assertEquals(manifestRepositoryUrl, scm.getManifestRepositoryUrl());
+ }
+}
diff --git a/src/test/java/hudson/plugins/repo/Security2478Test.java b/src/test/java/hudson/plugins/repo/Security2478Test.java
new file mode 100644
index 0000000..d2f8637
--- /dev/null
+++ b/src/test/java/hudson/plugins/repo/Security2478Test.java
@@ -0,0 +1,76 @@
+package hudson.plugins.repo;
+
+import hudson.model.FreeStyleBuild;
+import hudson.model.FreeStyleProject;
+import hudson.model.Result;
+import hudson.slaves.DumbSlave;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.jvnet.hudson.test.Issue;
+import org.jvnet.hudson.test.JenkinsRule;
+
+public class Security2478Test {
+
+ @Rule
+ public JenkinsRule rule = new JenkinsRule();
+
+ @Rule
+ public TemporaryFolder testFolder = new TemporaryFolder();
+
+ @Issue("SECURITY-2478")
+ @Test
+ public void checkoutShouldAbortWhenUrlIsNonRemoteAndBuildOnController() throws Exception {
+ FreeStyleProject freeStyleProject = rule.createFreeStyleProject();
+ String manifestRepositoryUrl = testFolder.newFolder().toString();
+ RepoScm scm = new RepoScm(manifestRepositoryUrl);
+ freeStyleProject.setScm(scm);
+ FreeStyleBuild freeStyleBuild = rule.assertBuildStatus(Result.FAILURE, freeStyleProject.scheduleBuild2(0));
+ rule.assertLogContains("Checkout of Repo url '" + manifestRepositoryUrl +
+ "' aborted because it references a local directory, " +
+ "which may be insecure. You can allow local checkouts anyway by setting the system property '" +
+ RepoScm.ALLOW_LOCAL_CHECKOUT_PROPERTY + "' to true.", freeStyleBuild);
+ }
+
+ @Issue("SECURITY-2478")
+ @Test
+ public void checkoutShouldNotAbortWhenUrlIsNonRemoteAndEscapeHatchTrue() throws Exception {
+ try {
+ RepoScm.ALLOW_LOCAL_CHECKOUT = true;
+ FreeStyleProject freeStyleProject = rule.createFreeStyleProject();
+ String manifestRepositoryUrl = testFolder.newFolder().toString();
+ RepoScm scm = new RepoScm(manifestRepositoryUrl);
+ freeStyleProject.setScm(scm);
+ FreeStyleBuild freeStyleBuild = rule.assertBuildStatus(Result.FAILURE, freeStyleProject.scheduleBuild2(0));
+
+ // build fails because of manifestRepositoryUrl is not a repo(git) repository, but we don't care,
+ // we verify that build was not aborted because of RepoScm uses local path.
+ rule.assertLogNotContains("Checkout of Repo url '" + manifestRepositoryUrl +
+ "' aborted because it references a local directory, " +
+ "which may be insecure. You can allow local checkouts anyway by setting the system property '" +
+ RepoScm.ALLOW_LOCAL_CHECKOUT_PROPERTY + "' to true.", freeStyleBuild);
+ } finally {
+ RepoScm.ALLOW_LOCAL_CHECKOUT = false;
+ }
+ }
+
+ @Issue("SECURITY-2478")
+ @Test
+ public void checkoutShouldNotAbortWhenUrlIsNonRemoteAndBuildOnAgent() throws Exception {
+ DumbSlave agent = rule.createOnlineSlave();
+ FreeStyleProject freeStyleProject = rule.createFreeStyleProject();
+
+ String manifestRepositoryUrl = testFolder.newFolder().toString();
+
+ RepoScm scm = new RepoScm(manifestRepositoryUrl);
+ freeStyleProject.setScm(scm);
+ freeStyleProject.setAssignedLabel(agent.getSelfLabel());
+
+ // build fails because of manifestRepositoryUrl is not a repo(git) repository, but we don't care,
+ // we verify that build was not aborted because of RepoScm uses local path.
+ rule.assertLogNotContains("Checkout of Repo url '" + manifestRepositoryUrl +
+ "' aborted because it references a local directory, " +
+ "which may be insecure. You can allow local checkouts anyway by setting the system property '" +
+ RepoScm.ALLOW_LOCAL_CHECKOUT_PROPERTY + "' to true.", freeStyleProject.scheduleBuild2(0).get());
+ }
+}
diff --git a/src/test/java/hudson/plugins/repo/TestProjectState.java b/src/test/java/hudson/plugins/repo/TestProjectState.java
new file mode 100644
index 0000000..d6ead42
--- /dev/null
+++ b/src/test/java/hudson/plugins/repo/TestProjectState.java
@@ -0,0 +1,68 @@
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2011, Brad Larson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package hudson.plugins.repo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for the {@link RevisionState} class.
+ */
+public class TestProjectState extends TestCase {
+
+ private ProjectState projectStateA = ProjectState.constructCachedInstance("a", "a",
+ "c9039e9649d133d80073e432816b9b4915776b41");
+
+
+ private ProjectState projectStateB = ProjectState.constructCachedInstance("b", "b",
+ "fa822eff984195ec8923718cd025fd44b77a26ef");
+
+ private ProjectState projectStateA2 = ProjectState.constructCachedInstance("a", "a",
+ "c9039e9649d133d80073e432816b9b4915776b41");
+
+
+ /**
+ * Test {@link ProjectState#constructCachedInstance(String, String, String)}
+ */
+ public void testCaching()
+ {
+ Assert.assertTrue(projectStateA == projectStateA2);
+ Assert.assertFalse(projectStateA == projectStateB);
+ Assert.assertFalse(projectStateB == projectStateA2);
+ }
+
+ /**
+ * Test {@link ProjectState#equals(Object)}.
+ */
+ public void testEquality()
+ {
+ Assert.assertTrue(projectStateA.equals(projectStateA2));
+ Assert.assertFalse(projectStateA.equals(projectStateB));
+ Assert.assertFalse(projectStateB.equals(projectStateA2));
+ }
+}
diff --git a/src/test/java/hudson/plugins/repo/TestRepoScm.java b/src/test/java/hudson/plugins/repo/TestRepoScm.java
new file mode 100644
index 0000000..d9c1bbb
--- /dev/null
+++ b/src/test/java/hudson/plugins/repo/TestRepoScm.java
@@ -0,0 +1,74 @@
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2011, Brad Larson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package hudson.plugins.repo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for the {@link RevisionState} class.
+ */
+public class TestRepoScm extends TestCase {
+
+
+ public void testSetIgnoredProjects() {
+ RepoScm scm = new RepoScm("http://manifesturl");
+ scm.setIgnoreProjects("");
+ assertEquals("", scm.getIgnoreProjects());
+
+ }
+
+ public void testSetIgnoredProjectsKeepsOrder() {
+ RepoScm scm = new RepoScm("http://manifesturl");
+ scm.setIgnoreProjects("projecta projectb");
+ assertEquals("projecta\nprojectb", scm.getIgnoreProjects());
+ scm.setIgnoreProjects("projectb projecta");
+ assertEquals("projectb\nprojecta", scm.getIgnoreProjects());
+ }
+
+ public void testResetFirst() {
+ RepoScm scm = new RepoScm("http://manifesturl");
+ assertEquals(false, scm.isResetFirst());
+ scm.setResetFirst(true);
+ assertEquals(true, scm.isResetFirst());
+ }
+
+ public void testCleanFirst() {
+ RepoScm scm = new RepoScm("http://manifesturl");
+ assertEquals(false, scm.isCleanFirst());
+ scm.setCleanFirst(true);
+ assertEquals(true, scm.isCleanFirst());
+ }
+
+ public void testWorktree() {
+ RepoScm scm = new RepoScm("http://manifesturl");
+ assertEquals(false, scm.isWorktree());
+ scm.setWorktree(true);
+ assertEquals(true, scm.isWorktree());
+ }
+}
diff --git a/src/test/java/hudson/plugins/repo/TestRevisionState.java b/src/test/java/hudson/plugins/repo/TestRevisionState.java
index e152d0d..271825a 100644
--- a/src/test/java/hudson/plugins/repo/TestRevisionState.java
+++ b/src/test/java/hudson/plugins/repo/TestRevisionState.java
@@ -40,6 +40,8 @@ public class TestRevisionState extends TestCase {
private RevisionState stateOneCopy;
private RevisionState stateTwo;
private RevisionState stateThree;
+ private RevisionState stateMChange;
+
private String manifestOne =
""
@@ -72,10 +74,12 @@ public class TestRevisionState extends TestCase {
protected void setUp() throws Exception {
super.setUp();
- stateOne = new RevisionState(manifestOne, "master", null);
- stateOneCopy = new RevisionState(manifestOne, "master", null);
- stateTwo = new RevisionState(manifestTwo, "master", null);
- stateThree = new RevisionState(manifestThree, "master", null);
+ stateOne = new RevisionState(manifestOne, "a", "https://my.gerrit.com/myrepo", "master", "default.xml", null);
+ stateOneCopy = new RevisionState(manifestOne, "a", "https://my.gerrit.com/myrepo", "master", "default.xml", null);
+ stateTwo = new RevisionState(manifestTwo, "a", "https://my.gerrit.com/myrepo", "master", "default.xml", null);
+ stateThree = new RevisionState(manifestThree, "a", "https://my.gerrit.com/myrepo", "master", "default.xml", null);
+
+ stateMChange = new RevisionState(manifestThree, "b", "https://my.gerrit.com/myrepo", "master", "default.xml", null);
}
/**
@@ -85,6 +89,7 @@ public void testEquality() {
Assert.assertTrue(stateOne.equals(stateOneCopy));
Assert.assertFalse(stateOne.equals(stateTwo));
Assert.assertFalse(stateTwo.equals(stateThree));
+ Assert.assertFalse(stateThree.equals(stateMChange));
}
/**
@@ -95,15 +100,15 @@ public void testChangeDetection() {
List changes = stateTwo.whatChanged(stateOne);
List expectedChanges = new ArrayList();
- expectedChanges.add(new ProjectState("a", "a", "c9039e9649d133d80073e432816b9b4915776b41"));
- expectedChanges.add(new ProjectState("c", "c", "fa822eff984195ec8923718cd025fd44b77a26ef"));
- expectedChanges.add(new ProjectState("d", "d", null));
+ expectedChanges.add(ProjectState.constructCachedInstance("a", "a", "c9039e9649d133d80073e432816b9b4915776b41"));
+ expectedChanges.add(ProjectState.constructCachedInstance("c", "c", "fa822eff984195ec8923718cd025fd44b77a26ef"));
+ expectedChanges.add(ProjectState.constructCachedInstance("d", "d", null));
Assert.assertEquals(expectedChanges, changes);
changes = stateThree.whatChanged(stateTwo);
expectedChanges.clear();
- expectedChanges.add(new ProjectState("b", "b", "c27d6b02c859b291878db67f256cefac3adb26df"));
- expectedChanges.add(new ProjectState("c", "c", "7086d7305fa6c7c1930de1e7d96fffc9c819b479"));
+ expectedChanges.add(ProjectState.constructCachedInstance("b", "b", "c27d6b02c859b291878db67f256cefac3adb26df"));
+ expectedChanges.add(ProjectState.constructCachedInstance("c", "c", "7086d7305fa6c7c1930de1e7d96fffc9c819b479"));
Assert.assertEquals(expectedChanges, changes);
}
}