Tabnine Logo
GHRef
Code IndexAdd Tabnine to your IDE (free)

How to use
GHRef
in
org.kohsuke.github

Best Java code snippets using org.kohsuke.github.GHRef (Showing top 20 results out of 315)

origin: org.kohsuke/github-api

/**
 * Updates this ref to the specified commit.
 *
 * @param sha
 *      The SHA1 value to set this reference to
 */
public void updateTo(String sha) throws IOException {
 updateTo(sha, false);
}
origin: io.jenkins.updatebot/updatebot-core

public static void deleteUpdateBotBranch(GHRepository ghRepository, String branchName) throws IOException {
  if (branchName.startsWith("updatebot-")) {
    //delete as per https://github.com/kohsuke/github-api/pull/164#issuecomment-78391771
    //heads needed as per https://developer.github.com/v3/git/refs/#get-a-reference
    ghRepository.getRef("heads/" + branchName).delete();
    LOG.info("deleted branch " + branchName + " for " + ghRepository.getFullName());
  }
}
origin: kohsuke/github-api

/*package*/ static GHRef[] wrap(GHRef[] in, GitHub root) {
  for (GHRef r : in) {
    r.wrap(root);
  }
  return in;
}
origin: org.eclipse.che.selenium/che-selenium-core

public String getDefaultBranchSha() throws IOException {
 return getReferenceToDefaultBranch().getObject().getSha();
}
origin: org.eclipse.che.selenium/che-selenium-core

/**
 * Creates reference to the new branch with {@code branch} from default branch.
 *
 * @param branchName name of the branch which should be created
 * @return reference to the new branch
 * @throws IOException
 */
public GHRef createBranch(String branchName) throws IOException {
 GHRef defaultBranch = getReferenceToDefaultBranch();
 return ghRepo.createRef("refs/heads/" + branchName, defaultBranch.getObject().getSha());
}
origin: org.kohsuke/github-api

/*package*/ static GHRef[] wrap(GHRef[] in, GitHub root) {
  for (GHRef r : in) {
    r.wrap(root);
  }
  return in;
}
origin: org.eclipse.che.selenium/che-selenium-core

/**
 * Creates reference to the new tag with {@code tagName} from default branch.
 *
 * @param tagName is a name of new tag
 * @return reference to the new tag
 * @throws IOException
 */
public GHRef createTag(String tagName) throws IOException {
 GHRef defaultBranch = getReferenceToDefaultBranch();
 return ghRepo.createRef("refs/tags/" + tagName, defaultBranch.getObject().getSha());
}
origin: kohsuke/github-api

/**
 * Updates this ref to the specified commit.
 *
 * @param sha
 *      The SHA1 value to set this reference to
 */
public void updateTo(String sha) throws IOException {
 updateTo(sha, false);
}
origin: jenkinsci/ghprb-plugin

private void deleteBranch(Run<?, ?> build, Launcher launcher, final TaskListener listener) {
  if (!getDeleteOnMerge()) {
    return;
  }
  String branchName = pr.getHead().getRef();
  try {
    GHRepository repo = pr.getRepository();
    GHRef ref = repo.getRef("heads/" + branchName);
    ref.delete();
    listener.getLogger().println("Deleted branch " + branchName);
  } catch (IOException e) {
    listener.getLogger().println("Unable to delete branch " + branchName);
    e.printStackTrace(listener.getLogger());
  }
}
origin: org.sonarsource.sonar-plugins.github/github-api

/*package*/ static GHRef[] wrap(GHRef[] in, GitHub root) {
  for (GHRef r : in) {
    r.wrap(root);
  }
  return in;
}
origin: org.jenkins-ci.plugins/github-branch-source

@Override
public long lastModified() {
  if (repo == null) {
    return 0L;
  }
  synchronized (this) {
    if (!open) {
      return 0L;
    }
  }
  if (revision instanceof AbstractGitSCMSource.SCMRevisionImpl) {
    try {
      GHCommit commit = repo.getCommit(((AbstractGitSCMSource.SCMRevisionImpl) revision).getHash());
      return commit.getCommitDate().getTime();
    } catch (IOException e) {
      // ignore
    }
  } else if (revision == null) {
    try {
      GHRef ref = repo.getRef(this.ref);
      GHCommit commit = repo.getCommit(ref.getObject().getSha());
      return commit.getCommitDate().getTime();
    } catch (IOException e) {
      // ignore
    }
  }
  return 0;
}
origin: org.sonarsource.sonar-plugins.github/github-api

/**
 * Updates this ref to the specified commit.
 *
 * @param sha
 *      The SHA1 value to set this reference to
 */
public void updateTo(String sha) throws IOException {
 updateTo(sha, false);
}
origin: org.sonarsource.sonar-plugins.github/github-api

/**
 * Retrieves all refs for the github repository.
 * @return an array of GHRef elements coresponding with the refs in the remote repository.
 * @throws IOException on failure communicating with GitHub
 */
public GHRef[] getRefs() throws IOException {
  return GHRef.wrap(root.retrieve().to(String.format("/repos/%s/%s/git/refs", owner.login, name), GHRef[].class),root);
}
origin: groupon/DotCi

public org.kohsuke.github.GHCommit getHeadCommitForBranch(final String branch) throws IOException {
  String sha;
  final GitBranch gitBranch = new GitBranch(branch);
  if (gitBranch.isPullRequest()) {
    try {
      sha = getGithubRepository().getPullRequest(gitBranch.pullRequestNumber()).getHead().getSha();
    } catch (final IOException e) {
      throw new RuntimeException(e);
    }
  } else {
    try {
      final GHRef ref = getRef("heads/" + gitBranch);
      sha = ref.getObject().getSha();
    } catch (final IOException e) {
      sha = gitBranch.toString();
    }
  }
  return getGithubRepository().getCommit(sha);
}
origin: org.eclipse.che.selenium/che-selenium-core

private void createSubmodule(
  TestGitHubRepository pathToRootContentDirectory, String pathForSubmodule) throws IOException {
 String submoduleSha = createTreeWithSubmodule(pathToRootContentDirectory, pathForSubmodule);
 GHCommit treeCommit =
   ghRepo.createCommit().tree(submoduleSha).message("Create submodule").create();
 getReferenceToDefaultBranch().updateTo(treeCommit.getSHA1(), true);
 setupSubmoduleConfig(pathToRootContentDirectory, pathForSubmodule);
}
origin: org.sonarsource.sonar-plugins.github/github-api

/**
 * Retrieves all refs of the given type for the current GitHub repository.
 * @param refType the type of reg to search for e.g. <tt>tags</tt> or <tt>commits</tt>
 * @return an array of all refs matching the request type
 * @throws IOException on failure communicating with GitHub, potentially due to an invalid ref type being requested
 */
public GHRef[] getRefs(String refType) throws IOException {
  return GHRef.wrap(root.retrieve().to(String.format("/repos/%s/%s/git/refs/%s", owner.login, name, refType), GHRef[].class),root);
}
/**
origin: org.jenkins-ci.plugins/github-branch-source

switch (prhead.getCheckoutStrategy()) {
  case MERGE:
    baseHash = ghRepository.getRef("heads/" + prhead.getTarget().getName()).getObject().getSha();
    break;
  default:
return new SCMRevisionImpl(head, ghRepository.getRef("heads/" + head.getName()).getObject().getSha());
origin: org.sonarsource.sonar-plugins.github/github-api

/**
 * Retrive a ref of the given type for the current GitHub repository.
 * 
 * @param refName
 *            eg: heads/branch
 * @return refs matching the request type
 * @throws IOException
 *             on failure communicating with GitHub, potentially due to an
 *             invalid ref type being requested
 */
public GHRef getRef(String refName) throws IOException {
  return root.retrieve().to(String.format("/repos/%s/%s/git/refs/%s", owner.login, name, refName), GHRef.class).wrap(root);
}
/**
origin: org.kohsuke/github-api

/**
 * Retrieves all refs for the github repository.
 * @return an array of GHRef elements coresponding with the refs in the remote repository.
 * @throws IOException on failure communicating with GitHub
 */
public GHRef[] getRefs() throws IOException {
  return GHRef.wrap(root.retrieve().to(String.format("/repos/%s/%s/git/refs", getOwnerName(), name), GHRef[].class), root);
}
origin: kohsuke/github-api

/**
 * Retrieves all refs for the github repository.
 * @return an array of GHRef elements coresponding with the refs in the remote repository.
 * @throws IOException on failure communicating with GitHub
 */
public GHRef[] getRefs() throws IOException {
  return GHRef.wrap(root.retrieve().to(String.format("/repos/%s/%s/git/refs", getOwnerName(), name), GHRef[].class), root);
}
org.kohsuke.githubGHRef

Javadoc

Provides information on a Git ref from GitHub.

Most used methods

  • getObject
    The object that this ref points to.
  • updateTo
    Updates this ref to the specified commit.
  • delete
    Deletes this ref from the repository using the GitHub API.
  • wrap

Popular in Java

  • Finding current android device location
  • getSupportFragmentManager (FragmentActivity)
  • compareTo (BigDecimal)
  • getApplicationContext (Context)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now