本文整理汇总了Java中git4idea.commands.Git类的典型用法代码示例。如果您正苦于以下问题:Java Git类的具体用法?Java Git怎么用?Java Git使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Git类属于git4idea.commands包,在下文中一共展示了Git类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GithubCreatePullRequestWorker
import git4idea.commands.Git; //导入依赖的package包/类
private GithubCreatePullRequestWorker(@NotNull Project project,
@NotNull Git git,
@NotNull GitRepository gitRepository,
@NotNull GithubAuthDataHolder authHolder,
@NotNull GithubFullPath path,
@NotNull String remoteName,
@NotNull String remoteUrl,
@NotNull String currentBranch) {
myProject = project;
myGit = git;
myGitRepository = gitRepository;
myAuthHolder = authHolder;
myPath = path;
myRemoteName = remoteName;
myRemoteUrl = remoteUrl;
myCurrentBranch = currentBranch;
myForks = new ArrayList<ForkInfo>();
}
示例2: testExistingFreshGit
import git4idea.commands.Git; //导入依赖的package包/类
public void testExistingFreshGit() throws Throwable {
registerDefaultShareDialogHandler();
registerDefaultUntrackedFilesDialogHandler();
createProjectFiles();
Git git = ServiceManager.getService(Git.class);
git.init(myProject, myProjectRoot);
GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
checkNotification(NotificationType.INFORMATION, "Successfully shared project on GitHub", null);
initGitChecks();
checkGitExists();
checkGithubExists();
checkRemoteConfigured();
checkLastCommitPushed();
}
示例3: GitCrlfProblemsDetector
import git4idea.commands.Git; //导入依赖的package包/类
private GitCrlfProblemsDetector(@NotNull Project project, @NotNull GitPlatformFacade platformFacade, @NotNull Git git,
@NotNull Collection<VirtualFile> files) {
myProject = project;
myPlatformFacade = platformFacade;
myGit = git;
Map<VirtualFile, List<VirtualFile>> filesByRoots = sortFilesByRoots(files);
boolean shouldWarn = false;
Collection<VirtualFile> rootsWithIncorrectAutoCrlf = getRootsWithIncorrectAutoCrlf(filesByRoots);
if (!rootsWithIncorrectAutoCrlf.isEmpty()) {
Map<VirtualFile, Collection<VirtualFile>> crlfFilesByRoots = findFilesWithCrlf(filesByRoots, rootsWithIncorrectAutoCrlf);
if (!crlfFilesByRoots.isEmpty()) {
Map<VirtualFile, Collection<VirtualFile>> crlfFilesWithoutAttrsByRoots = findFilesWithoutAttrs(crlfFilesByRoots);
shouldWarn = !crlfFilesWithoutAttrsByRoots.isEmpty();
}
}
myShouldWarn = shouldWarn;
}
示例4: getUpdater
import git4idea.commands.Git; //导入依赖的package包/类
/**
* Returns proper updater based on the update policy (merge or rebase) selected by user or stored in his .git/config
* @return {@link GitMergeUpdater} or {@link GitRebaseUpdater}.
*/
@NotNull
public static GitUpdater getUpdater(@NotNull Project project,
@NotNull Git git,
@NotNull Map<VirtualFile, GitBranchPair> trackedBranches,
@NotNull VirtualFile root,
@NotNull ProgressIndicator progressIndicator,
@NotNull UpdatedFiles updatedFiles,
@NotNull UpdateMethod updateMethod) {
if (updateMethod == UpdateMethod.BRANCH_DEFAULT) {
updateMethod = resolveUpdateMethod(project, root);
}
return updateMethod == UpdateMethod.REBASE ?
new GitRebaseUpdater(project, git, root, trackedBranches, progressIndicator, updatedFiles):
new GitMergeUpdater(project, git, root, trackedBranches, progressIndicator, updatedFiles);
}
示例5: fetchNatively
import git4idea.commands.Git; //导入依赖的package包/类
@NotNull
private static GitFetchResult fetchNatively(@NotNull GitRepository repository, @NotNull GitRemote remote, @Nullable String branch) {
Git git = ServiceManager.getService(Git.class);
String[] additionalParams = branch != null ?
new String[]{ getFetchSpecForBranch(branch, remote.getName()) } :
ArrayUtil.EMPTY_STRING_ARRAY;
GitFetchPruneDetector pruneDetector = new GitFetchPruneDetector();
GitCommandResult result = git.fetch(repository, remote,
Collections.<GitLineHandlerListener>singletonList(pruneDetector), additionalParams);
GitFetchResult fetchResult;
if (result.success()) {
fetchResult = GitFetchResult.success();
}
else if (result.cancelled()) {
fetchResult = GitFetchResult.cancel();
}
else {
fetchResult = GitFetchResult.error(result.getErrorOutputAsJoinedString());
}
fetchResult.addPruneInfo(pruneDetector.getPrunedRefs());
return fetchResult;
}
示例6: GitPreservingProcess
import git4idea.commands.Git; //导入依赖的package包/类
public GitPreservingProcess(@NotNull Project project,
@NotNull GitPlatformFacade facade,
@NotNull Git git,
@NotNull Collection<VirtualFile> rootsToSave,
@NotNull String operationTitle,
@NotNull String destinationName,
@NotNull GitVcsSettings.UpdateChangesPolicy saveMethod,
@NotNull ProgressIndicator indicator,
@NotNull Runnable operation) {
myProject = project;
myFacade = facade;
myGit = git;
myRootsToSave = rootsToSave;
myOperationTitle = operationTitle;
myDestinationName = destinationName;
myProgressIndicator = indicator;
myOperation = operation;
myStashMessage = String.format("Uncommitted changes before %s at %s", StringUtil.capitalize(myOperationTitle),
DateFormatUtil.formatDateTime(Clock.getTime()));
mySaver = configureSaver(saveMethod);
}
示例7: GitRebaseProcess
import git4idea.commands.Git; //导入依赖的package包/类
private GitRebaseProcess(@NotNull Project project,
@NotNull List<GitRepository> allRepositories,
@NotNull GitRebaseParams params,
@NotNull GitChangesSaver saver,
@NotNull MultiMap<GitRepository, GitRebaseUtils.CommitInfo> skippedCommits,
@NotNull Map<GitRepository, SuccessType> successfulRepositories) {
myProject = project;
myAllRepositories = allRepositories;
myParams = params;
mySaver = saver;
mySuccessfulRepositories = successfulRepositories;
myGit = ServiceManager.getService(Git.class);
myChangeListManager = ChangeListManager.getInstance(myProject);
myNotifier = VcsNotifier.getInstance(myProject);
myFacade = ServiceManager.getService(GitPlatformFacade.class);
myInitialHeadPositions = readInitialHeadPositions(myAllRepositories);
mySkippedCommits = skippedCommits;
}
示例8: GitBranchOperation
import git4idea.commands.Git; //导入依赖的package包/类
protected GitBranchOperation(@NotNull Project project, @NotNull GitPlatformFacade facade, @NotNull Git git,
@NotNull GitBranchUiHandler uiHandler, @NotNull Collection<GitRepository> repositories) {
myProject = project;
myFacade = facade;
myGit = git;
myUiHandler = uiHandler;
myRepositories = repositories;
myCurrentHeads = ContainerUtil.map2Map(repositories, new Function<GitRepository, Pair<GitRepository, String>>() {
@Override
public Pair<GitRepository, String> fun(GitRepository repository) {
GitLocalBranch currentBranch = repository.getCurrentBranch();
return Pair.create(repository, currentBranch == null ? repository.getCurrentRevision() : currentBranch.getName());
}
});
mySuccessfulRepositories = new ArrayList<GitRepository>();
myRemainingRepositories = new ArrayList<GitRepository>(myRepositories);
mySettings = myFacade.getSettings(myProject);
}
示例9: pushChangesToRemoteRepo
import git4idea.commands.Git; //导入依赖的package包/类
private boolean pushChangesToRemoteRepo(final Project project, final GitRepository localRepository,
final com.microsoft.alm.sourcecontrol.webapi.model.GitRepository remoteRepository,
final ServerContext localContext, final ProgressIndicator indicator) {
localRepository.update();
final String remoteGitUrl = UrlHelper.getCmdLineFriendlyUrl(remoteRepository.getRemoteUrl());
//push all branches in local Git repo to remote
indicator.setText(TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_GIT_PUSH));
final Git git = ServiceManager.getService(Git.class);
final GitCommandResult result = git.push(localRepository, REMOTE_ORIGIN, remoteGitUrl, "*", true);
if (!result.success()) {
logger.error("pushChangesToRemoteRepo: push to remote: {} failed with error: {}, outuput: {}",
remoteGitUrl, result.getErrorOutputAsJoinedString(), result.getOutputAsJoinedString());
notifyImportError(project,
result.getErrorOutputAsJoinedString(),
ACTION_NAME, localContext);
return false;
}
return true;
}
示例10: testExistingFreshGit
import git4idea.commands.Git; //导入依赖的package包/类
public void testExistingFreshGit() throws Throwable {
registerDefaultShareDialogHandler();
registerDefaultUntrackedFilesDialogHandler();
createProjectFiles();
Git git = ServiceManager.getService(Git.class);
git.init(myProject, myProjectRoot);
GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
checkNotification(NotificationType.INFORMATION, "Successfully shared project on GitHub", null);
checkGitExists();
checkGithubExists();
checkRemoteConfigured();
checkLastCommitPushed();
}
示例11: getUpdater
import git4idea.commands.Git; //导入依赖的package包/类
/**
* Returns proper updater based on the update policy (merge or rebase) selected by user or stored in his .git/config
* @return {@link GitMergeUpdater} or {@link GitRebaseUpdater}.
*/
@NotNull
public static GitUpdater getUpdater(@NotNull Project project, @NotNull Git git, @NotNull Map<VirtualFile, GitBranchPair> trackedBranches,
@NotNull VirtualFile root, @NotNull ProgressIndicator progressIndicator,
@NotNull UpdatedFiles updatedFiles) {
final GitVcsSettings settings = GitVcsSettings.getInstance(project);
if (settings == null) {
return getDefaultUpdaterForBranch(project, git, root, trackedBranches, progressIndicator, updatedFiles);
}
switch (settings.getUpdateType()) {
case REBASE:
return new GitRebaseUpdater(project, git, root, trackedBranches, progressIndicator, updatedFiles);
case MERGE:
return new GitMergeUpdater(project, git, root, trackedBranches, progressIndicator, updatedFiles);
case BRANCH_DEFAULT:
// use default for the branch
return getDefaultUpdaterForBranch(project, git, root, trackedBranches, progressIndicator, updatedFiles);
}
return getDefaultUpdaterForBranch(project, git, root, trackedBranches, progressIndicator, updatedFiles);
}
示例12: testReturnsExpectedUrl
import git4idea.commands.Git; //导入依赖的package包/类
@Test
@UseDataProvider("urlProvider")
public void testReturnsExpectedUrl(String url, String expected) throws RemoteException
{
GitRemote gitRemote = mock(GitRemote.class);
Git git = mock(Git.class);
when(gitRemote.getFirstUrl()).thenReturn(url);
Remote remote = new Remote(git, gitRemote);
assertEquals(expected, remote.url().toString());
}
示例13: testDoesThrowWhenRemoteUrlNotFound
import git4idea.commands.Git; //导入依赖的package包/类
@Test(expected = RemoteException.class)
public void testDoesThrowWhenRemoteUrlNotFound() throws RemoteException
{
GitRemote gitRemote = mock(GitRemote.class);
Git git = mock(Git.class);
when(gitRemote.getFirstUrl()).thenReturn(null);
Remote remote = new Remote(git, gitRemote);
remote.url();
}
示例14: GitResetOperation
import git4idea.commands.Git; //导入依赖的package包/类
public GitResetOperation(@NotNull Project project, @NotNull Map<GitRepository, VcsFullCommitDetails> targetCommits,
@NotNull GitResetMode mode, @NotNull ProgressIndicator indicator) {
myProject = project;
myCommits = targetCommits;
myMode = mode;
myIndicator = indicator;
myGit = ServiceManager.getService(Git.class);
myNotifier = VcsNotifier.getInstance(project);
myFacade = ServiceManager.getService(GitPlatformFacade.class);
myUiHandler = new GitBranchUiHandlerImpl(myProject, myFacade, myGit, indicator);
}
示例15: GitDefineRemoteDialog
import git4idea.commands.Git; //导入依赖的package包/类
GitDefineRemoteDialog(@NotNull GitRepository repository, @NotNull Git git) {
super(repository.getProject());
myRepository = repository;
myGit = git;
myRemoteName = new JTextField(GitRemote.ORIGIN_NAME, 20);
myRemoteUrl = new JTextField(20);
setTitle("Define Remote");
init();
}