本文整理汇总了Java中org.eclipse.jgit.lib.RepositoryState类的典型用法代码示例。如果您正苦于以下问题:Java RepositoryState类的具体用法?Java RepositoryState怎么用?Java RepositoryState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RepositoryState类属于org.eclipse.jgit.lib包,在下文中一共展示了RepositoryState类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: toggleCommitButton
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
/**
* Checks if the commit button should be enabled.
*
* @param forceEnable <code>true</code> to make the button enable without any additional checks.
*/
private void toggleCommitButton(boolean forceEnable) {
boolean enable = false;
if (forceEnable) {
enable = true;
} else {
try {
RepositoryState repositoryState = gitAccess.getRepository().getRepositoryState();
if (repositoryState == RepositoryState.MERGING_RESOLVED
&& gitAccess.getStagedFiles().isEmpty() && gitAccess.getUnstagedFiles().isEmpty()) {
enable = true;
commitMessage.setText(translator.getTranslation(Tags.CONCLUDE_MERGE_MESSAGE));
} else if (!gitAccess.getStagedFiles().isEmpty()) {
enable = true;
} else if (repositoryState == RepositoryState.MERGING
&& translator.getTranslation(Tags.CONCLUDE_MERGE_MESSAGE).equals(commitMessage.getText())) {
commitMessage.setText("");
}
} catch (NoRepositorySelected e) {
// Remains disabled
}
}
commitButton.setEnabled(enable);
}
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:31,代码来源:CommitPanel.java
示例2: setup
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
@BeforeMethod
public void setup() {
jGitConnection =
spy(
new JGitConnection(
repository, credentialsLoader, sshKeyProvider, eventService, userResolver));
RepositoryState repositoryState = mock(RepositoryState.class);
GitUser gitUser = mock(GitUser.class);
when(repositoryState.canAmend()).thenReturn(true);
when(repositoryState.canCommit()).thenReturn(true);
when(repository.getRepositoryState()).thenReturn(repositoryState);
when(gitUser.getName()).thenReturn("username");
when(gitUser.getEmail()).thenReturn("email");
when(userResolver.getUser()).thenReturn(gitUser);
when(repository.getDirectory()).thenReturn(directory);
when(directory.getPath()).thenReturn("path");
}
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:JGitConnectionTest.java
示例3: canMerge
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
private boolean canMerge(final Repository repository) {
String message = null;
Exception ex = null;
try {
Ref head = repository.getRef(Constants.HEAD);
if (head == null || !head.isSymbolic())
message = UIText.MergeAction_HeadIsNoBranch;
else if (!repository.getRepositoryState().equals(
RepositoryState.SAFE))
message = NLS.bind(UIText.MergeAction_WrongRepositoryState,
repository.getRepositoryState());
else if (!head.getLeaf().getName().startsWith("refs/heads/features")) { //$NON-NLS-1$
message = "Current branch is not a feature branch.";
}
} catch (IOException e) {
message = e.getMessage();
ex = e;
}
if (message != null)
org.eclipse.egit.ui.Activator.handleError(message, ex, true);
return (message == null);
}
开发者ID:Genuitec,项目名称:gerrit-tools,代码行数:24,代码来源:MergeStableIntoCurrentBranchCommand.java
示例4: getRepositoryState
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
/**
* @return the state of the current repository or <code>null</code>, if there's no repository selected.
*/
private RepositoryState getRepositoryState() {
RepositoryState repositoryState = null;
Repository repo = getCurrentRepository();
if (repo != null) {
repositoryState = repo.getRepositoryState();
}
return repositoryState;
}
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:12,代码来源:ChangesPanel.java
示例5: isRepoInMergingState
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
/**
* Check if the repository is in merging state.
*
* @return <code>true</code> if the repository is in merging state.
*/
private boolean isRepoInMergingState() {
boolean toReturn = false;
Repository repo = getCurrentRepository();
if (repo != null) {
RepositoryState repositoryState = repo.getRepositoryState();
toReturn = repositoryState == RepositoryState.MERGING_RESOLVED
|| repositoryState == RepositoryState.MERGING;
}
return toReturn;
}
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:16,代码来源:ChangesPanel.java
示例6: push
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
/**
* Pushes all the commits from the local repository to the remote repository
*
* @param username
* - Git username
* @param password
* - Git password
*
* @throws GitAPIException
* @throws TransportException
* @throws InvalidRemoteException
*/
public PushResponse push(final String username, final String password)
throws GitAPIException {
AuthenticationInterceptor.install();
PushResponse response = new PushResponse();
RepositoryState repositoryState = git.getRepository().getRepositoryState();
if (repositoryState == RepositoryState.MERGING) {
response.setStatus(org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
response.setMessage(translator.getTranslation(Tags.PUSH_WITH_CONFLICTS));
return response;
}
if (getPullsBehind() > 0) {
response.setStatus(org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
response.setMessage(translator.getTranslation(Tags.BRANCH_BEHIND));
return response;
}
String sshPassphrase = OptionsManager.getInstance().getSshPassphrase();
Iterable<PushResult> call = git.push()
.setCredentialsProvider(new SSHUserCredentialsProvider(username, password, sshPassphrase)).call();
Iterator<PushResult> results = call.iterator();
logger.debug("Push Ended");
while (results.hasNext()) {
PushResult result = results.next();
for (RemoteRefUpdate info : result.getRemoteUpdates()) {
response.setStatus(info.getStatus());
return response;
}
}
response.setStatus(org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
response.setMessage(translator.getTranslation(Tags.PUSH_FAILED_UNKNOWN));
return response;
}
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:48,代码来源:GitAccess.java
示例7: testRestartMerge
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
@Test
public void testRestartMerge() throws Exception {
pushOneFileToRemote();
gitAccess.setRepository(SECOND_LOCAL_TEST_REPOSITORY);
OptionsManager.getInstance().saveSelectedRepository(SECOND_LOCAL_TEST_REPOSITORY);
File file = new File(SECOND_LOCAL_TEST_REPOSITORY + "/test.txt");
file.createNewFile();
PrintWriter out = new PrintWriter(LOCAL_TEST_REPOSITPRY + "/test.txt");
out.println("teeeeeest");
out.close();
gitAccess.add(new FileStatus(GitChangeType.ADD, "test.txt"));
gitAccess.commit("conflict");
gitAccess.pull("", "");
for (FileStatus fileStatus : gitAccess.getUnstagedFiles()) {
if(fileStatus.getChangeType() == GitChangeType.CONFLICT){
gitAccess.add(fileStatus);
}
}
RepositoryState actual = gitAccess.getRepository().getRepositoryState();
RepositoryState expected = RepositoryState.MERGING_RESOLVED;
assertEquals(expected, actual);
gitAccess.restartMerge();
actual = gitAccess.getRepository().getRepositoryState();
expected = RepositoryState.MERGING;
assertEquals(expected, actual);
}
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:31,代码来源:GitAccessConflictTest.java
示例8: hasStagedFiles
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
@Override
public boolean hasStagedFiles() {
if ( git.getRepository().getRepositoryState() == RepositoryState.SAFE ) {
return !getStagedFiles().isEmpty();
} else {
return git.getRepository().getRepositoryState().canCommit();
}
}
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:9,代码来源:UIGit.java
示例9: run
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
@Override
protected void run () throws GitException {
Repository repository = getRepository();
ObjectId originalCommit = getOriginalCommit();
ObjectId head = getHead();
List<RebaseTodoLine> steps;
try {
switch (operation) {
case BEGIN:
// initialize sequencer and cherry-pick steps if there are
// more commits to cherry-pick
steps = prepareCommand(head);
// apply the selected steps
applySteps(steps, false);
break;
case ABORT:
// delete the sequencer and reset to the original head
if (repository.getRepositoryState() == RepositoryState.CHERRY_PICKING
|| repository.getRepositoryState() == RepositoryState.CHERRY_PICKING_RESOLVED) {
if (originalCommit == null) {
// maybe the sequencer is not created in that case simply reset to HEAD
originalCommit = head;
}
}
Utils.deleteRecursively(getSequencerFolder());
if (originalCommit != null) {
ResetCommand reset = new ResetCommand(repository, getClassFactory(),
originalCommit.name(), GitClient.ResetType.HARD, new DelegatingGitProgressMonitor(monitor), listener);
reset.execute();
}
result = createCustomResult(GitCherryPickResult.CherryPickStatus.ABORTED);
break;
case QUIT:
// used to reset the sequencer only
Utils.deleteRecursively(getSequencerFolder());
switch (repository.getRepositoryState()) {
case CHERRY_PICKING:
// unresolved conflicts
result = createResult(CherryPickResult.CONFLICT);
break;
case CHERRY_PICKING_RESOLVED:
result = createCustomResult(GitCherryPickResult.CherryPickStatus.UNCOMMITTED);
break;
default:
result = createCustomResult(GitCherryPickResult.CherryPickStatus.OK);
break;
}
break;
case CONTINUE:
switch (repository.getRepositoryState()) {
case CHERRY_PICKING:
// unresolved conflicts, cannot continue
result = createResult(CherryPickResult.CONFLICT);
break;
case CHERRY_PICKING_RESOLVED:
// cannot continue without manual commit
result = createCustomResult(GitCherryPickResult.CherryPickStatus.UNCOMMITTED);
break;
default:
// read steps from sequencer and apply them
// if sequencer is empty this will be a noop
steps = readTodoFile(repository);
applySteps(steps, true);
break;
}
break;
default:
throw new IllegalStateException("Unexpected operation " + operation.name());
}
} catch (GitAPIException | IOException ex) {
throw new GitException(ex);
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:74,代码来源:CherryPickCommand.java
示例10: testRepositoryState
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
public void testRepositoryState () {
for (RepositoryState state : RepositoryState.values()) {
assertNotNull(GitRepositoryState.getStateFor(state));
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:GitEnumsStateTest.java
示例11: getRepositoryState
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
/**
* Returns the current state of the repository this client is associated with.
* The state indicates what commands may be run on the repository and if the repository
* requires any additional commands to get into the normal state.
* @param monitor progress monitor
* @return current repository state
* @throws GitException an unexpected error occurs
*/
public GitRepositoryState getRepositoryState (ProgressMonitor monitor) throws GitException {
Repository repository = gitRepository.getRepository();
RepositoryState state = repository.getRepositoryState();
return GitRepositoryState.getStateFor(state);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:GitClient.java
示例12: isMergingResolved
import org.eclipse.jgit.lib.RepositoryState; //导入依赖的package包/类
/**
* Check if the merging has been resolved.
*
* @param repositoryState the repository state.
*
* @return <code>true</code> if the merging has been resolved.
*/
private boolean isMergingResolved() {
RepositoryState repositoryState = getRepositoryState();
return repositoryState != null && repositoryState == RepositoryState.MERGING_RESOLVED;
}
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:12,代码来源:ChangesPanel.java
注:本文中的org.eclipse.jgit.lib.RepositoryState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论