当前位置: 首页>>代码示例>>Java>>正文


Java Status类代码示例

本文整理汇总了Java中org.eclipse.jgit.api.Status的典型用法代码示例。如果您正苦于以下问题:Java Status类的具体用法?Java Status怎么用?Java Status使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Status类属于org.eclipse.jgit.api包,在下文中一共展示了Status类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: backup

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
public synchronized void backup() throws Exception {
    repo.add().setUpdate(false).addFilepattern(".").call();
    Status status = repo.status().setIgnoreSubmodules(SubmoduleWalk.IgnoreSubmoduleMode.ALL).call();
    log.debug("status.getUncommittedChanges() = " + status.getUncommittedChanges());
    if (!status.getUncommittedChanges().isEmpty()) {
        for (String missingPath : status.getMissing()) {
            repo.rm().addFilepattern(missingPath).call();
        }

        log.info("Changes detected in the following files: " + status.getUncommittedChanges());
        repo.commit()
            .setMessage("Backing up data dir")
            .setAuthor("AppRunner BackupService", "[email protected]")
            .call();
        Iterable<PushResult> pushResults = repo.push().call();
        for (PushResult pushResult : pushResults) {
            log.info("Result of pushing to remote: " + pushResult.getRemoteUpdates());
        }
    } else {
        log.info("No changes to back up");
    }

}
 
开发者ID:danielflower,项目名称:app-runner,代码行数:24,代码来源:BackupService.java

示例2: getConflictingFiles

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
/**
 * Gets the conflicting file from the git status
 * 
 * @return the conflicting files list
 */
public List<FileStatus> getConflictingFiles() {
	if (git != null) {
		try {
			Status status = git.status().call();
			List<FileStatus> stagedFiles = new ArrayList<FileStatus>();
			for (String fileName : status.getConflicting()) {
				stagedFiles.add(new FileStatus(GitChangeType.CONFLICT, fileName));
			}

			return stagedFiles;
		} catch (GitAPIException e) {
			if (logger.isDebugEnabled()) {
				logger.debug(e, e);
			}
		}
	}

	return new ArrayList<FileStatus>();
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:25,代码来源:GitAccess.java

示例3: getUnstagedFiles

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
@Override
public List<UIFile> getUnstagedFiles() {
  List<UIFile> files = new ArrayList<UIFile>();
  Status status = null;
  try {
    status = git.status().call();
  } catch ( Exception e ) {
    e.printStackTrace();
    return files;
  }
  status.getUntracked().forEach( name -> {
    files.add( new UIFile( name, ChangeType.ADD, false ) );
  } );
  status.getModified().forEach( name -> {
    files.add( new UIFile( name, ChangeType.MODIFY, false ) );
  } );
  status.getConflicting().forEach( name -> {
    files.add( new UIFile( name, ChangeType.MODIFY, false ) );
  } );
  status.getMissing().forEach( name -> {
    files.add( new UIFile( name, ChangeType.DELETE, false ) );
  } );
  return files;
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:25,代码来源:UIGit.java

示例4: getStagedFiles

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
@Override
public List<UIFile> getStagedFiles() {
  List<UIFile> files = new ArrayList<UIFile>();
  Status status = null;
  try {
    status = git.status().call();
  } catch ( Exception e ) {
    e.printStackTrace();
    return files;
  }
  status.getAdded().forEach( name -> {
    files.add( new UIFile( name, ChangeType.ADD, true ) );
  } );
  status.getChanged().forEach( name -> {
    files.add( new UIFile( name, ChangeType.MODIFY, true ) );
  } );
  status.getRemoved().forEach( name -> {
    files.add( new UIFile( name, ChangeType.DELETE, true ) );
  } );
  return files;
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:22,代码来源:UIGit.java

示例5: processPushResult

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
private void processPushResult( Iterable<PushResult> resultIterable ) throws Exception {
  resultIterable.forEach( result -> { // for each (push)url
    StringBuilder sb = new StringBuilder();
    result.getRemoteUpdates().stream()
      .filter( update -> update.getStatus() != RemoteRefUpdate.Status.OK )
      .filter( update -> update.getStatus() != RemoteRefUpdate.Status.UP_TO_DATE )
      .forEach( update -> { // for each failed refspec
        sb.append(
          result.getURI().toString()
          + "\n" + update.getSrcRef().toString()
          + "\n" + update.getStatus().toString()
          + ( update.getMessage() == null ? "" : "\n" + update.getMessage() )
          + "\n\n"
        );
      } );
    if ( sb.length() == 0 ) {
      showMessageBox( BaseMessages.getString( PKG, "Dialog.Success" ), BaseMessages.getString( PKG, "Dialog.Success" ) );
    } else {
      showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), sb.toString() );
    }
  } );
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:23,代码来源:UIGit.java

示例6: revertPath

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
@Override
public void revertPath( String path ) {
  try {
    // Delete added files
    Status status = git.status().addPath( path ).call();
    if ( status.getUntracked().size() != 0 || status.getAdded().size() != 0 ) {
      resetPath( path );
      org.apache.commons.io.FileUtils.deleteQuietly( new File( directory, path ) );
    }

    /*
     * This is a work-around to discard changes of conflicting files
     * Git CLI `git checkout -- conflicted.txt` discards the changes, but jgit does not
     */
    git.add().addFilepattern( path ).call();

    git.checkout().setStartPoint( Constants.HEAD ).addPath( path ).call();
    org.apache.commons.io.FileUtils.deleteQuietly( new File( directory, path + ".ours" ) );
    org.apache.commons.io.FileUtils.deleteQuietly( new File( directory, path + ".theirs" ) );
  } catch ( Exception e ) {
    showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), e.getMessage() );
  }
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:24,代码来源:UIGit.java

示例7: testStashWithUntractked

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
@Test
public void testStashWithUntractked() throws IOException, GitAPIException, GitOperationException {
    try (Git git = Git.wrap(repository)) {
        writeTrashFile("test", "This is readme");
        writeTrashFile("notTractedFile", "this file is untracked");

        git.add().addFilepattern("test").call();

        gitMgr.createStash(ws, false, null);

        Status status = git.status().call();

        assertEquals(0, status.getAdded().size());
        assertEquals(1, status.getUntracked().size());

        gitMgr.applyStash(ws, null, false, false);

        status = git.status().call();

        assertEquals(1, status.getAdded().size());
        assertEquals(1, status.getUntracked().size());
    }
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:24,代码来源:GitManagerTest.java

示例8: refreshTree

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
public void refreshTree(Status status) {
    int totalSize = status.getAdded().size() + status.getChanged().size() + status.getMissing().size();

    changedFiles = new ArrayList<>(totalSize);
    // TODO: this probably doesn't account for files that were moved / renamed
    status.getAdded()  .forEach(file -> changedFiles.add(new ModifiedPath(Paths.get(file), GitFileStatus.ADDED)));
    status.getChanged().forEach(file -> changedFiles.add(new ModifiedPath(Paths.get(file), GitFileStatus.MODIFIED)));
    status.getMissing().forEach(file -> changedFiles.add(new ModifiedPath(Paths.get(file), GitFileStatus.REMOVED)));

    fileSelectionStates = new ArrayList<>(totalSize);

    buildRoot();
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:14,代码来源:SelectableFileViewer.java

示例9: commitAllChanges

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
public void commitAllChanges(final String message) {
    final Repository repository = getRepository();
    try {
        final Git git = new Git(repository);
        git.add().addFilepattern(".").call();
        final Status status = git.status().call();
        if (status.getChanged().size() > 0 || status.getAdded().size() > 0
                || status.getModified().size() > 0
                || status.getRemoved().size() > 0) {
            final RevCommit rev = git.commit().setAll(true)
                    .setCommitter(person).setAuthor(person)
                    .setMessage(message).call();
            LOGGER.info("Git commit " + rev.getName() + " [" + message
                    + "]");
        }
    }
    catch (final Exception e) {
        throw new IllegalStateException(
                "Could not commit changes to local Git repository", e);
    }
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:22,代码来源:GitOperationsImpl.java

示例10: hasCleanWorkingDirectory

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
public static Matcher<Git> hasCleanWorkingDirectory() {
	return new TypeSafeDiagnosingMatcher<Git>() {
		@Override
		protected boolean matchesSafely(final Git git, final Description mismatchDescription) {
			try {
				final Status status = git.status().call();
				if (!status.isClean()) {
					final String start = "Uncommitted changes in ";
					final String end = " at " + git.getRepository().getWorkTree().getAbsolutePath();
					mismatchDescription.appendValueList(start, ", ", end, status.getUncommittedChanges());
				}
				return status.isClean();
			} catch (final GitAPIException e) {
				throw new RuntimeException("Error checking git status", e);
			}
		}

		@Override
		public void describeTo(final Description description) {
			description.appendText("A git directory with no staged or unstaged changes");
		}
	};
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:24,代码来源:GitMatchers.java

示例11: addTest

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
@Test
public void addTest() throws Exception {

    Repository repository = getTestRepository();
   
    File fileToAdd = new File(gitLocalRepo, filenameToAdd);
    fileToAdd.createNewFile();
    
    template.send("direct:add", new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
        }
    });
    File gitDir = new File(gitLocalRepo, ".git");
    assertEquals(gitDir.exists(), true);
    
    Status status = new Git(repository).status().call();
    assertTrue(status.getAdded().contains(filenameToAdd));
    repository.close();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:GitProducerTest.java

示例12: statusTest

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
@Test
public void statusTest() throws Exception {

    Repository repository = getTestRepository();
    
    File fileToAdd = new File(gitLocalRepo, filenameToAdd);
    fileToAdd.createNewFile();
    
    template.send("direct:add", new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
        }
    });
    File gitDir = new File(gitLocalRepo, ".git");
    assertEquals(gitDir.exists(), true);
    
    Status status = template.requestBody("direct:status", "", Status.class);
    assertTrue(status.getAdded().contains(filenameToAdd));
    
    repository.close();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:GitProducerTest.java

示例13: GitPushWindow

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
/**
 * The constructor should first build the main layout, set the
 * composition root and then do any custom initialization.
 *
 * The constructor will not be automatically regenerated by the
 * visual editor.
 * @param git 
 * @param status 
 */
public GitPushWindow(Git git, File target, Status status) {
	buildMainLayout();
	//setCompositionRoot(mainLayout);
	setContent(mainLayout);
	//
	// Save data
	//
	this.git = git;
	this.target = target;
	this.container = new GitStatusContainer(status);
	//
	// Set our shortcuts
	//
	this.setCloseShortcut(KeyCode.ESCAPE);
	//
	// Initialize GUI
	//
	this.initializeText();
	this.initializeTable(status);
	this.initializeButtons();
	//
	//  Focus
	//
	this.textAreaComments.focus();
}
 
开发者ID:apache,项目名称:incubator-openaz,代码行数:35,代码来源:GitPushWindow.java

示例14: initializeTable

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
protected void initializeTable(Status status) {
	//
	// Setup the table
	//
	this.tableChanges.setContainerDataSource(this.container);
	this.tableChanges.setPageLength(this.container.size());
	this.tableChanges.setImmediate(true);
	//
	// Generate column
	//
	this.tableChanges.addGeneratedColumn("Entry", new ColumnGenerator() {
		private static final long serialVersionUID = 1L;

		@Override
		public Object generateCell(Table source, Object itemId, Object columnId) {
			Item item = self.container.getItem(itemId);
			assert item != null;
			if (item instanceof StatusItem) {
				return self.generateGitEntryComponent(((StatusItem) item).getGitEntry());
			}
			assert item instanceof StatusItem;
			return null;
		}
	});
}
 
开发者ID:apache,项目名称:incubator-openaz,代码行数:26,代码来源:GitPushWindow.java

示例15: hasCleanWorkingDirectory

import org.eclipse.jgit.api.Status; //导入依赖的package包/类
public static Matcher<Git> hasCleanWorkingDirectory() {
    return new TypeSafeDiagnosingMatcher<Git>() {
        @Override
        protected boolean matchesSafely(Git git, Description mismatchDescription) {
            try {
                Status status = git.status().call();
                if (!status.isClean()) {
                    String start = "Uncommitted changes in ";
                    String end = " at " + git.getRepository().getWorkTree().getAbsolutePath();
                    mismatchDescription.appendValueList(start, ", ", end, status.getUncommittedChanges());
                }
                return status.isClean();
            } catch (GitAPIException e) {
                throw new RuntimeException("Error checking git status", e);
            }
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("A git directory with no staged or unstaged changes");
        }
    };
}
 
开发者ID:danielflower,项目名称:multi-module-maven-release-plugin,代码行数:24,代码来源:GitMatchers.java


注:本文中的org.eclipse.jgit.api.Status类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。