GitHub API v4: How can I traverse with pagination? (GraphQL)

According to graphql documentation there are more than one pagination model. GitHub is using complete connection model In this model you can traverse with adding after:”Y3Vyc29yOjEwMA==” to your search query. query { search(first: 100, after:”Y3Vyc29yOjEwMA==”, type:USER, query:”location:usa repos:>0 language:java”) { pageInfo { startCursor hasNextPage endCursor } userCount nodes { … on User { bio company … Read more

How to use GitHub V3 API to get commit count for a repo?

Make a request on https://api.github.com/repos/{username}/{repo}/commits?sha={branch}&per_page=1&page=1 Now just take the Link parameter of the response header and grab out the page count situated just before rel=”last” This page count is equal to the total number of commits in that branch! The trick was to use &per_page=1&page=1. It distributed 1 commit in 1 page. So, the total … Read more

GitHub GraphQL equivalent of the contents API

After some digging, found it: query { repository(name: “repoName”, owner: “repoOwner”) { object(expression: “branch:path/to/file”) { … on Blob { text } } } } The argument passed to expression on the object field is actually a git revision expression suitable for rev-parse, so I guess you can have fun with it to do advanced querying. … Read more

Homebrew: how to use the formula from the pull request

You can install a Homebrew formula directly from a pull request by using brew install $raw_pull_requst_url, eg: brew install https://raw.github.com/ColinHebert/homebrew/538a99cc06a8f40b6ebcf2f4f8fd44d563c672cd/Library/Formula/emacs.rb For finding the pull request URL, there’s probably a better way, but I went to the pull request URL you linked, clicked on Files Changed, then on View File @ 9b22d42, then finally on Raw

Finding total contributions of a user from GitHub API

Answers for 2019, Use GitHub API V4. First go to GitHub to apply for a token: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line. step 7, scopes select only read:user cUrl curl -H “Authorization: bearer token” -X POST -d ‘{“query”:”query {\n user(login: \”MeiK2333\”) {\n name\n contributionsCollection {\n contributionCalendar {\n colors\n totalContributions\n weeks {\n contributionDays {\n color\n contributionCount\n date\n weekday\n }\n firstDay\n }\n … Read more

How to create a gist on command line

Recently GitHub CLI released. So you can now use it instead. Just install it to your system (https://github.com/cli/cli#installation) The authenticate (it’s pretty simple) gh auth login After you logged in you can simply create a new gist by: gh gist create -d “my test gist” -f some_local_file.txt test_gist For more details you can use help: … Read more

Commenting a pull request in a GitHub action

A canonical way is using the official Github Script actions. Don’t get confused, issues and PRs are the same for the GitHub API. 2020: on: # Trigger the workflow on push or pull request pull_request: branches: – master – develop jobs: comment: runs-on: ubuntu-latest steps: – uses: actions/github-script@v3 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | github.issues.createComment({ issue_number: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)