use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class GitCommandLine method getUploadedPrivateKey.
@NotNull
private File getUploadedPrivateKey(@NotNull AuthSettings authSettings) throws Exception {
final String keyId = authSettings.getTeamCitySshKeyId();
final VcsRoot root = authSettings.getRoot();
if (keyId == null || root == null || mySshKeyManager == null) {
final String msg = "Failed to locate uploaded SSH key " + keyId + " for vcs root %s " + (mySshKeyManager == null ? ": null ssh key manager" : "");
Loggers.VCS.warn(String.format(msg, LogUtil.describe(root)));
throw new VcsException(String.format(msg, root == null ? null : root.getName()));
}
final TeamCitySshKey key = mySshKeyManager.getKey(root);
if (key == null) {
throw new VcsException("Failed to locate uploaded SSH key " + keyId + " for vcs root " + root.getName());
}
final File privateKey = createTmpKeyFile();
addPostAction(() -> FileUtil.delete(privateKey));
FileUtil.writeFileAndReportErrors(privateKey, new String(key.getPrivateKey()));
return privateKey;
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class LatestAcceptedRevisionTest method merge_commit_tree_does_not_have_difference_with_parents.
/**
* This test is for the following case:
* <pre>
* o m3
* / \
* m1 o o m2
* | \/ |
* c1 o o c2
* | /
* o
* </pre>
* Here m1 and m2 have the same trees, so when m3 is created there is no diff between m3 & m1 and m3 & m2.
* So although both c1 & c2 change interesting files we won't see a diff in trees in m3 comparing to its parents and
* can think that nothing interesting was changed, while this is not true.
*/
public void merge_commit_tree_does_not_have_difference_with_parents() throws VcsException, IOException {
GitVcsSupport support = git();
VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
ensureFetchPerformed(support, root, "refs/heads/master", "6399724fac6ec9c62e8795fc037ad385e873911f");
String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
// m3 is 6394695f179d87f7f5fc712e12dfac0ed0d98652
then(rev).isEqualTo("6394695f179d87f7f5fc712e12dfac0ed0d98652");
rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src/File6.java"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
then(rev).isEqualTo("6394695f179d87f7f5fc712e12dfac0ed0d98652");
rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src/File7.java"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
then(rev).isEqualTo("6394695f179d87f7f5fc712e12dfac0ed0d98652");
rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test/TestFile5.java"), "6399724fac6ec9c62e8795fc037ad385e873911f", Collections.emptySet(), null);
then(rev).isEqualTo("8fc8c2a8baf37a71a2cdd0c2b0cd1eedfd1649e8");
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class LatestAcceptedRevisionTest method branch_merged_to_master.
public void branch_merged_to_master() throws IOException, VcsException {
GitVcsSupport support = git();
VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
ensureFetchPerformed(support, root, "refs/heads/master", "b304522994197be5f336d58cc34edc11cbda095e");
String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:src"), "b304522994197be5f336d58cc34edc11cbda095e", Collections.emptySet());
then(rev).isEqualTo("bb6ab65d23fa0ffbaa61d44c8241f127cf0f323f");
rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test"), "b304522994197be5f336d58cc34edc11cbda095e", Collections.emptySet());
then(rev).isEqualTo("b265fd1608fe17f912a031312e1efc758c4e8a35");
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class LatestAcceptedRevisionTest method test_include_all_exclude_all.
public void test_include_all_exclude_all() throws IOException, VcsException {
GitVcsSupport support = git();
VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
ensureFetchPerformed(support, root, "refs/heads/master", "bbdf67dc5d1d2fa1ce08a0c7db7371f14cd918bf");
String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:."), "bbdf67dc5d1d2fa1ce08a0c7db7371f14cd918bf", Collections.emptySet());
then(rev).isEqualTo("bbdf67dc5d1d2fa1ce08a0c7db7371f14cd918bf");
rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("-:."), "bbdf67dc5d1d2fa1ce08a0c7db7371f14cd918bf", Collections.emptySet());
then(rev).isNull();
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class LatestAcceptedRevisionTest method traverse_through_merges_looking_for_interesting_commit.
public void traverse_through_merges_looking_for_interesting_commit() throws VcsException, IOException {
GitVcsSupport support = git();
VcsRoot root = vcsRoot().withFetchUrl(myRepo).build();
ensureFetchPerformed(support, root, "refs/heads/master", "6d8cc5e06db390a20f5b2bf278206a0ec47f05dc");
Set<String> visited = new HashSet<>();
String rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test/subDir"), "6ff32b16fe485e7a0a1e209bf10987e1ad46292e", Collections.emptySet(), visited);
then(rev).isEqualTo("be6e6b68e84b5aec8a022a8b2d740ed39a7c63b9");
then(visited).containsOnly("6ff32b16fe485e7a0a1e209bf10987e1ad46292e", "eea4a3e48901ba036998c9fe0afdc78cc8a05a33", "1330f191b990a389459e28f8754c913e9b417c93", "75c9325d5b129f299fba8567f0fd7f599d336e8f", "be6e6b68e84b5aec8a022a8b2d740ed39a7c63b9");
visited.clear();
rev = support.getCollectChangesPolicy().getLatestRevisionAcceptedByCheckoutRules(root, new CheckoutRules("+:test/TestFile4.java"), "6ff32b16fe485e7a0a1e209bf10987e1ad46292e", Collections.emptySet(), visited);
then(rev).isEqualTo("40224a053e16145562d1befa3d0a127c54f5dbff");
then(visited).containsOnly("6ff32b16fe485e7a0a1e209bf10987e1ad46292e", "ce92302a768ce0763e83aebf8c0e16e102c8d06b", "d036d012385a762568a474b57337b9cf398b96e0", "40224a053e16145562d1befa3d0a127c54f5dbff");
}
Aggregations