blob: 24400066e7f5bd14ebb00a6d74d9255057886f86 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*******************************************************************************
* Copyright (C) 2011, 2014 Dariusz Luksza <dariusz@luksza.org> and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.egit.core.synchronize.dto;
import static org.eclipse.jgit.lib.Constants.HEAD;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.util.Arrays;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.core.test.GitTestCase;
import org.eclipse.egit.core.test.TestRepository;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig;
import org.junit.Before;
import org.junit.Test;
public class GitSynchronizeDataTest extends GitTestCase {
private Repository repo;
@Override
@Before
public void setUp() throws Exception {
super.setUp();
TestRepository testRepo = new TestRepository(gitDir);
testRepo.connect(project.project);
repo = RepositoryMapping.getMapping(project.project).getRepository();
// make initial commit
try (Git git = new Git(repo)) {
git.commit().setAuthor("JUnit", "junit@jgit.org")
.setMessage("Initial commit").call();
}
}
@Test
public void shouldReturnDstMergeForRemoteBranch() throws Exception {
// given
StoredConfig config = repo.getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
remoteConfig.setFetchRefSpecs(Arrays.asList(new RefSpec("+refs/heads/*:refs/remotes/origin/*")));
remoteConfig.update(config);
GitSynchronizeData gsd = new GitSynchronizeData(repo, HEAD,
"refs/remotes/origin/master", false);
assertThat(gsd.getDstRemoteName(), is("origin"));
assertThat(gsd.getDstMerge(), is("refs/heads/master"));
}
}
|