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


Java RefUpdate.link方法代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.RefUpdate.link方法的典型用法代码示例。如果您正苦于以下问题:Java RefUpdate.link方法的具体用法?Java RefUpdate.link怎么用?Java RefUpdate.link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.lib.RefUpdate的用法示例。


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

示例1: create

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public void create() throws IOException, ConfigInvalidException {
  try (Repository git = mgr.openRepository(allProjectsName)) {
    initAllProjects(git);
  } catch (RepositoryNotFoundException notFound) {
    // A repository may be missing if this project existed only to store
    // inheritable permissions. For example 'All-Projects'.
    try (Repository git = mgr.createRepository(allProjectsName)) {
      initAllProjects(git);
      RefUpdate u = git.updateRef(Constants.HEAD);
      u.link(RefNames.REFS_CONFIG);
    } catch (RepositoryNotFoundException err) {
      String name = allProjectsName.get();
      throw new IOException("Cannot create repository " + name, err);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:AllProjectsCreator.java

示例2: call

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
@Override
public Ref call() throws GitAPIException, RefNotFoundException,
	CheckoutConflictException, InvalidRefNameException,
	RefAlreadyExistsException
{
	this.checkCallable();
	try {
		this.processOptions();
		this.checkoutStartPoint();
		RefUpdate update = this.getRepository().updateRef(Constants.HEAD);
		Result r = update.link(this.getBranchName());
		if (EnumSet.of(Result.NEW, Result.FORCED).contains(r) == false) {
			throw new JGitInternalException(MessageFormat.format(
				JGitText.get().checkoutUnexpectedResult, r.name()));
		}
		this.setCallable(false);
		return this.getRepository().getRef(Constants.HEAD);
	}
	catch (IOException e) {
		throw new JGitInternalException(e.getMessage(), e);
	}
}
 
开发者ID:uw-loci,项目名称:github-backup-java,代码行数:23,代码来源:CreateOrphanBranchCommand.java

示例3: linkRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
public static void linkRef(RefUpdate refUpdate, String target) {
	try {
		RefUpdate.Result result = refUpdate.link(target);
		if (result != RefUpdate.Result.FORCED && result != RefUpdate.Result.NEW && result != RefUpdate.Result.NO_CHANGE)
			throw new RefUpdateException(result);
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:10,代码来源:GitUtils.java

示例4: createLocally

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private static void createLocally(URIish uri, String head) {
  try (Repository repo = new FileRepository(uri.getPath())) {
    repo.create(true /* bare */);

    if (head != null) {
      RefUpdate u = repo.updateRef(Constants.HEAD);
      u.disableRefLog();
      u.link(head);
    }
  } catch (IOException e) {
    repLog.error(String.format("Error creating local repository %s:\n", uri.getPath()), e);
  }
}
 
开发者ID:GerritCodeReview,项目名称:plugins_replication,代码行数:14,代码来源:ReplicationQueue.java

示例5: updateHeadLocally

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
private static void updateHeadLocally(URIish uri, String newHead) {
  try (Repository repo = new FileRepository(uri.getPath())) {
    if (newHead != null) {
      RefUpdate u = repo.updateRef(Constants.HEAD);
      u.link(newHead);
    }
  } catch (IOException e) {
    repLog.error(
        String.format("Failed to update HEAD of repository %s to %s", uri.getPath(), newHead), e);
  }
}
 
开发者ID:GerritCodeReview,项目名称:plugins_replication,代码行数:12,代码来源:ReplicationQueue.java

示例6: setHEADtoRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/**
 * Sets the symbolic ref HEAD to the specified target ref. The HEAD will be detached if the target ref is not a branch.
 * 
 * @param repository
 * @param targetRef
 * @return true if successful
 */
public static boolean setHEADtoRef(Repository repository, String targetRef) {
	try {
		// detach HEAD if target ref is not a branch
		boolean detach = !targetRef.startsWith(Constants.R_HEADS);
		RefUpdate.Result result;
		RefUpdate head = repository.updateRef(Constants.HEAD, detach);
		if (detach) { // Tag
			RevCommit commit = getCommit(repository, targetRef);
			head.setNewObjectId(commit.getId());
			result = head.forceUpdate();
		} else {
			result = head.link(targetRef);
		}
		switch (result) {
		case NEW:
		case FORCED:
		case NO_CHANGE:
		case FAST_FORWARD:
			return true;
		default:
			LOGGER.error(MessageFormat.format("{0} HEAD update to {1} returned result {2}", repository.getDirectory().getAbsolutePath(),
					targetRef, result));
		}
	} catch (Throwable t) {
		error(t, repository, "{0} failed to set HEAD to {1}", targetRef);
	}
	return false;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:36,代码来源:JGitUtils.java

示例7: setHEADtoRef

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/**
 * Sets the symbolic ref HEAD to the specified target ref. The
 * HEAD will be detached if the target ref is not a branch.
 *
 * @param repository
 * @param targetRef
 * @return true if successful
 */
public static boolean setHEADtoRef(Repository repository, String targetRef) {
	try {
		 // detach HEAD if target ref is not a branch
		boolean detach = !targetRef.startsWith(Constants.R_HEADS);
		RefUpdate.Result result;
		RefUpdate head = repository.updateRef(Constants.HEAD, detach);
		if (detach) { // Tag
			RevCommit commit = getCommit(repository, targetRef);
			head.setNewObjectId(commit.getId());
			result = head.forceUpdate();
		} else {
			result = head.link(targetRef);
		}
		switch (result) {
		case NEW:
		case FORCED:
		case NO_CHANGE:
		case FAST_FORWARD:
			return true;				
		default:
			LOGGER.error(MessageFormat.format("{0} HEAD update to {1} returned result {2}",
					repository.getDirectory().getAbsolutePath(), targetRef, result));
		}
	} catch (Throwable t) {
		error(t, repository, "{0} failed to set HEAD to {1}", targetRef);
	}
	return false;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:37,代码来源:JGitUtils.java

示例8: GitRepository

import org.eclipse.jgit.lib.RefUpdate; //导入方法依赖的package包/类
/**
 * Creates a new Git-backed repository.
 *
 * @param repoDir the location of this repository
 * @param format the repository format
 * @param repositoryWorker the {@link Executor} which will perform the blocking repository operations
 * @param creationTimeMillis the creation time
 * @param author the user who initiated the creation of this repository
 *
 * @throws StorageException if failed to create a new repository
 */
GitRepository(Project parent, File repoDir, GitRepositoryFormat format, Executor repositoryWorker,
              long creationTimeMillis, Author author) {

    this.parent = requireNonNull(parent, "parent");
    name = requireNonNull(repoDir, "repoDir").getName();
    this.repositoryWorker = requireNonNull(repositoryWorker, "repositoryWorker");
    this.format = requireNonNull(format, "format");

    requireNonNull(author, "author");

    final RepositoryBuilder repositoryBuilder = new RepositoryBuilder().setGitDir(repoDir).setBare();
    boolean success = false;
    try {
        // Create an empty repository with format version 0 first.
        try (org.eclipse.jgit.lib.Repository initRepo = repositoryBuilder.build()) {
            if (exist(repoDir)) {
                throw new StorageException(
                        "failed to create a repository at: " + repoDir + " (exists already)");
            }

            initRepo.create(true);

            final StoredConfig config = initRepo.getConfig();
            if (format == GitRepositoryFormat.V1) {
                // Update the repository settings to upgrade to format version 1 and reftree.
                config.setInt(CONFIG_CORE_SECTION, null, CONFIG_KEY_REPO_FORMAT_VERSION, 1);
            }

            // Disable hidden files, symlinks and file modes we do not use.
            config.setEnum(CONFIG_CORE_SECTION, null, CONFIG_KEY_HIDEDOTFILES, HideDotFiles.FALSE);
            config.setBoolean(CONFIG_CORE_SECTION, null, CONFIG_KEY_SYMLINKS, false);
            config.setBoolean(CONFIG_CORE_SECTION, null, CONFIG_KEY_FILEMODE, false);

            // Set the diff algorithm.
            config.setString(CONFIG_DIFF_SECTION, null, CONFIG_KEY_ALGORITHM, "histogram");

            // Disable rename detection which we do not use.
            config.setBoolean(CONFIG_DIFF_SECTION, null, CONFIG_KEY_RENAMES, false);

            config.save();
        }

        // Re-open the repository with the updated settings and format version.
        jGitRepository = new RepositoryBuilder().setGitDir(repoDir).build();

        // Initialize the master branch.
        final RefUpdate head = jGitRepository.updateRef(Constants.HEAD);
        head.disableRefLog();
        head.link(Constants.R_HEADS + Constants.MASTER);

        // Initialize the commit ID database.
        commitIdDatabase = new CommitIdDatabase(jGitRepository);

        // Insert the initial commit into the master branch.
        commit0(null, Revision.INIT, creationTimeMillis, author,
                "Create a new repository", "", Markup.PLAINTEXT,
                Collections.emptyList(), true);

        headRevision = Revision.INIT;
        success = true;
    } catch (IOException e) {
        throw new StorageException("failed to create a repository at: " + repoDir, e);
    } finally {
        if (!success) {
            close();
            // Failed to create a repository. Remove any cruft so that it is not loaded on the next run.
            deleteCruft(repoDir);
        }
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:82,代码来源:GitRepository.java


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