nodegit / nodegit/nodegit

how to checkout from head_sha ( github check_run )

Open
#1,659 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.8k
Forks
704
PR merge metrics
No merged PRs in 30d

Description

System information

  • node version: 10.15.3
  • npm or yarn version: 6.9.0
  • OS/version/architecture: Ubuntu 18.04.2 LTS / 4.15.0-47-generic / x64
  • Applicable nodegit version: 0.24.1
  • @types/nodegit version: 0.24.6

hi.
i'm porting below code to nodegit

Creating CI tests with the Checks API > Step 2.2. Cloning the repository

# Clones the repository to the current working directory, updates the
# contents using Git pull, and checks out the ref.
#
# full_repo_name  - The owner and repo. Ex: octocat/hello-world
# repository      - The repository name
# ref             - The branch, commit SHA, or tag to check out
def clone_repository(full_repo_name, repository, ref)
  @git = Git.clone("https://x-access-token:#{@installation_token.to_s}@github.com/#{full_repo_name}.git", repository)
  pwd = Dir.getwd()
  Dir.chdir(repository)
  @git.pull
  @git.checkout(ref)
  Dir.chdir(pwd)
end
# ***** RUN A CI TEST *****
full_repo_name = @payload['repository']['full_name']
repository     = @payload['repository']['name']
head_sha       = @payload['check_run']['head_sha']

clone_repository(full_repo_name, repository, head_sha)

but, can not checkout from 'commit SHA (head_sha)'

github check_run payload
{
"payload": {
  "check_run": {
    "head_sha": "002a9d7011784e9f77359611a0139deecb8d17f7",

Repository#checkoutBranch /
Repository#checkoutRef /
Commit.lookup > Commit#getTree > Checkout.tree
not working.

how can i do?

thanks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Repository#checkoutBranch and Repository#checkoutRef documentation, then review the Commit.lookup, Commit#getTree, and Checkout.tree references. Reproduce the checkout using the supplied head_sha and capture the failure details. Done means identifying a documented NodeGit checkout path for that commit SHA or clarifying the missing usage information.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, javascript, node.js
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.