217 questions
0
votes
0
answers
84
views
GitHub API endpoint no longer returning results for referral sources
When querying the referral sources endpoint on GitHub I'm only getting an empty list returned. I can get data for other endpoints in the same repo, even for other traffic endpoints. I'm expecting ...
0
votes
1
answer
53
views
How to unfollow someone using PyGitHub
I was wondering how would I unfollow someone using PyGithub
It's a program that unfollows every person that follows me (to follow organizations only)
I tried the following code but it gave me 404 page ...
1
vote
1
answer
111
views
GitHub file search by name results differ from web when using API or pyGitHub
I have a large git repo with multiple .Net solutions in it (in the example repo there is only one). I want to return the paths of all the Directory.Packages.props files within that specific repo. I am ...
1
vote
1
answer
264
views
Discrepancies Between GitHub API and Web Interface Search Results
I am currently facing issues with the GitHub Search API where the number of search results significantly differs from what I see on the GitHub web app. I would like to understand these discrepancies ...
0
votes
0
answers
47
views
Can't push a mp4 file to github with PyGithub
I am trying to push a mp4 file from my local storage to my github repo using PyGithub with the following code.
from github import Github
import base64
# Authenticate to GitHub
token = "my_token&...
0
votes
1
answer
176
views
How to get the default branch in PyGithub?
I was looking through the PyGithub documentation https://pygithub.readthedocs.io/en/latest/introduction.html but I can't find any function that returns the default branch.
In the examples, "main&...
0
votes
0
answers
136
views
Multiple files into single commit using PyGithub
I'm trying to add multiple files into a single commit using PyGithub.
I'm looping in my local directory to fetch all the files to be committed and then I'm trying to create a git blob for each.
Then I'...
0
votes
0
answers
82
views
edit_protection() got an unexpected keyword argument
branch.edit_protection(
enforce_admins=desired_protection_settings["enforce_admins"],
required_linear_history=desired_protection_settings["...
4
votes
2
answers
675
views
Download github issue attachments from private repos
I want to download the attachments in a GitHub issue programmatically.
Using the GitHub API Python SDK I can authenticate and get the Issues and comments for a private repository. The API doesn't have ...
1
vote
0
answers
108
views
How can I tell if my github branch has a Pull Request?
I tried passing the most recent SHA to Commit.get_pulls but that does not give expected results. It returns an empty paginatedList even though I have a PR for the SHA in question . . .
I'm using ...
0
votes
1
answer
724
views
How to get the status of a build on GithHub through PyGitHub
I have a text file with a list of repos. I wanted to use pygithub to iterate through the list and tell me for each repo on whether the last build was successful or failure on dev or master branch ...
2
votes
1
answer
174
views
Is there a way in Python GitHub library to check if the branch for which a PR has been raised is out-of-date from it's base branch or not?
My python script is getting a list of PRs and then it needs to run a check if the branches being used in those PRs are out-of-date from their base branch or not.
I need to perform this action remotely ...
0
votes
1
answer
50
views
PyGitHub: Get avatar of user?
How can we get the avatar of a GitHub user using PyGitHub?
Github.get_user gives NamedUser | AuthenticatedUser, however, neither NamedUser nor AuthenticatedUser have any functions for getting the ...
0
votes
1
answer
384
views
Using PyGithub, how do I get the last known update time for a repository?
I've been developing a portfolio website and part of the data for the projects (like the project summaries and the latest update times) are obtained through PyGithub using the project title.
When I ...
0
votes
1
answer
331
views
What's wrong with this Python function to upload file to github?
I have the following Python function to upload a file to github repository.
def upload_to_github(github_token: str,
source_file: str, destination_folder: str,
...
0
votes
1
answer
120
views
query github commits from a certain date using pygithub
have the following code:
from github import Github
...
g = github(token)
query = f'org:{org_name} author:{username} since=2021-10-19T00:00:00Z'
commits = g.search_commits(query, sort='author-date', ...
0
votes
1
answer
73
views
PyGitHub script has no errors but does not work
I have two csv files that update on a regular basis that supply data to Render for a dashboard. The entire process is automated except for pushing the new information to github, which I've been doing ...
1
vote
1
answer
1k
views
pygithub search and read specific files
I am using pyGithub to go through the files in the Github repository. The problem is, with this code my_code.get_contents(""), it goes through each and every file in all the folders and ...
0
votes
1
answer
55
views
Download the latest relase file with token from private repo
I want to download files from my private repository using python.
What should I do?
I tried something like this, but it doesn't work.
I also allowed everything in the token for testing, I get error ...
1
vote
0
answers
321
views
Github Api (PyGithub) delete/undo last commit to branch
Background
I am using a fork of the upstream repository where I created my own branch. I can commit to this branch and then create a pull request to the upstream. Committing again to the fork will ...
0
votes
3
answers
856
views
How to to convert raw contents of a large file stored on github to correct bytes array?
I believe the recommended method to get the contents of a large file stored on GitHub is to use REST API. For the files which size is 1MB-100MB, it's only possible to get raw contents (in string ...
0
votes
0
answers
278
views
Pygithub g.get_repo() working in local but not on github hosted and self hosted runners
I have a code which is working fine in my local but not on github actions.
token = "some-token"
repo_name = "customer-sandbox/some-repo" # org/repo format
g = Github(token)
repo = ...
0
votes
2
answers
672
views
How to read the contents of pdf files which encoding is `none`?
Upd: solved, see the comments below.
When I try to read the contents of some pdf files I get an empty string. I have noticed that this happens to pdf files which encoding is none, and it works fine ...
0
votes
0
answers
67
views
Using negative qualifiers with PyGithub
I am trying to use PyGithub to access GitHub REST API to search repos. Since, API has strict rate limits, I want to filter out as many repos possible during the search.
Before, writing the script in ...
0
votes
1
answer
2k
views
cannot import module Auth form Github by PyGitHub
I want to try PyGitHub a Python library to access the GitHub REST API.
python imterpreter: anaconda python 3.10
the first step, I install the command
pip install PyGithub
after that, I try to follow ...
3
votes
0
answers
564
views
How to get_projects() from github repo using PyGithub?
I'm trying to fetch projects from a github repo using PyGithub 1.58.1.
I created those projects manually in browser and I can see them.
But when I see repo.get_projects().totalCount, it's giving 0.
...
0
votes
2
answers
1k
views
Get specific tag from repository using PyGithub
I have this very simple code using PyGithub
from github import Github
g = Github('<offuscated token>')
repo = g.get_repo("telefonicaid/fiware-orion")
repo.get_git_tag("3.8.0"...
1
vote
0
answers
56
views
```AttributeError``` when attempting to call a repo action
I am receiving an error message of AttributeError when attempting to call a repo and its actions.
This is my current code:
from github import Github
#Authenticate with GitHub
g = Github("<...
1
vote
0
answers
104
views
"BadCredentialsException" error in jupyter when trying to call a github repo
Hello so I am receiving this error BadCredentialsException: 401 {"message": "Bad credentials", "documentation_url": "https://docs.github.com/rest"} when ...
1
vote
1
answer
2k
views
How to enable Require status checks to pass before merging through automation
I was reading over PyGitHub's documentation in: https://pygithub.readthedocs.io/en/latest/github_objects/Branch.html
and found some interesting methods that I thought might help
First I made sure that ...
0
votes
1
answer
370
views
Pushing files to github folders using PyGithub
I have a github directory called "latviadebate". It looks like this:
$ main
.
├── index.html
├── style.css
├── images
│ └── image1.png
│ └── image2.png
├── pages
│ └── 20-03-...
0
votes
1
answer
1k
views
github.GithubException.BadCredentialsException: 401 - but credentials are correct?
I developed a script which predicts some values and saves them into the predictions.csv file using github actions.
I then need to update the predictions.csv file on github, because i need to query it ...
1
vote
1
answer
598
views
PyGithub: How to create a branch off the master and check out?
How can I create a new branch off the master and check out the branch?
The documentation at https://pygithub.readthedocs.io/en/latest/ does not show how to do this.
Thanks a lot!!
1
vote
0
answers
143
views
Uploading multiple files to release on Github using Python
I am trying to create a release and upload all files with a specific ending as an asset. My code is as follows:
# This uploads all apkg files in the current directory to a release on GitHub.
import ...
2
votes
0
answers
757
views
How to get all users in organization in GitHub using PyGithub? I'm getting github.GithubException.UnknownObjectException
I would like to print all users in my organization in GitHub using PyGitHub.
The below snippet works, however it returns a PaginatedList:
python3 -c 'import os; from github import Github;g = Github(os....
1
vote
1
answer
320
views
Python test patch is never called
I am trying to test with my code by mocking the PyGithub library.
I want to create a repository for an organization. So first I need to get it and on the "Organization" returned object, I ...
0
votes
1
answer
227
views
Appending lines to a txt file on github through pygithub
The following accesses the data from a text file on git hub.
repoName = 'repo_url'
filePath = 'file.txt'
from github import Github
g = Github(TOKEN)
repo = g.get_repo(repoName)
file = repo....
2
votes
1
answer
4k
views
How do I programmatically extract GitHub repositories that contain a code string?
I am looking for a way to extract GitHub repositories containing files with a certain code string. I can do manually using the GitHub search bar. For instance, if I'm looking for the usages of the ...
0
votes
1
answer
1k
views
PyGithub: How to move inside a git branch and list all the content that present in sub folder
from github import Github
access_token = "MYACCESS_TOKEN"
g=Github(access_token, retry=20)
repo = g.get_repo("pygit/git")
print(repo.name)
branches = repo.get_branches()
for ...
0
votes
1
answer
250
views
How do I edit a Gist with pygithub?
I am trying to edit an already created gist using the pygithub library but I have been unable to do so thus far.
import github.InputFileContent
from github import Github
g = Github("priv key&...
0
votes
0
answers
310
views
Read a CSV file with PyGithub
I just want to read a CSV file from a Github repo with PyGithub.
from github import Github
g = Github(token)
repo = g.get_repo("user/example")
contents = repo.get_contents("h.csv")...
0
votes
1
answer
952
views
python script to print the last commit message from specific git branch
from github import Github
import sys
import requests
import subprocess
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(...
0
votes
1
answer
305
views
Git Fetch Upstream with Pygithub
I’m using a lambda function to deploy code to GitHub to a forked repository with the use of Pygithub. The forked repo will create a pr to the upstream repo where changes will be reviewed. Is there a ...
0
votes
1
answer
364
views
Is there a way in Python to find the results of a Github CI?
I am using PyGithub to run tests on every pull request in a repository.
I'd like to only run tests on pull requests that have passed my CI.
Is there a way to query the results of the CI in Python?
For ...
3
votes
1
answer
3k
views
Github API - how to get pull requests newer than some date
Corresponding to the official DOC, I prepare the following URL:
https://api.github.com/repos/gooddata/gooddata-python-sdk/pulls?per_page=10&page=1&sort=updated&direction=asc&state=all&...
0
votes
1
answer
677
views
How to check if public git repository is updated?
I would like to know how can one check that public git repository is updated or not (if their are new commits) using python. Help in this regard would be appreciated.
0
votes
0
answers
121
views
Update a file in GitHub using a local file
I am trying to write a script to update the contents of a file in a GitHub repo.
I have a File.txt that has the required data.
Here's the code I've written
from github import Github
g = Github(...
1
vote
2
answers
701
views
Download Repository to local folder and overwrite existing files by using Python
I have the problem that I want to update/overwrite my local folder with a Repository, but I cant find information about how I can do that with Python. When I am cloning it I have to have a empty ...
2
votes
1
answer
319
views
PyGithub - Can't set attribute error while trying to change default branch
I've written this code to change the default branch from "master" to "release".
from github import Github
g = Github("github token", verify=False, base_url="url to ...
4
votes
2
answers
2k
views
How to upload an image file to Github using PyGithub?
I want to upload an image file to my Github Repository using Pygithub.
from github import Github
g=Github("My Git Token")
repo=g.get_repo("My Repo")
content=repo.get_contents(&...