how to extract github issues programmatically - github-api

I know you can extract git logs by cloning the repository and running this command git log --pretty=format:"%H ,%an ,%ae ,%ad ,%cn ,%ce ,%cd ,%s" >OpenCV.csv but how can you extract git issues and the information inside it like the message of issue comment.

Related

Pushing a respository I initialised with git init inside another repository to github

I am currently doing course called fullstackopen for which I created a repository on Github called fso and cloned it locally using ssh. Inside fso, I created directories for different parts(part1, part2) and created react projects inside them (using create-react-app). I pushed them to github without any problems.
For part3, the course asked to create a new repository for the backend(node js). I created this repo inside fso/part3 using git init and initialised a node app called phonebook. Now, when I tried to push it to Github, I got this:
enter image description here
So, I added my github repo using:
git remote add origin
After this when I tried to push again, I was prompted for my username and password but support for password authentication has been removed. I tried pushing using personal access tokens and got this:
enter image description here
Can I run the following in my part3/phonebook (phonbook-backend) directory?
git pull origin master git push origin master
I'm not sure if this would work, I dont want to lose my work.
Edit: i tried git pull origin main --allow-unrelated-histories and got this
pushing after this results in the same error
this is what my directory structure looks like locally. Im trying to push part3 to my github repo
Your last error is 'updates were rejected because the remote contains work'
This happens when your repository gets initialized with additional files like README or GITIGNORE. To resolve this, first you need to pull your changes from server, so you can use below command:
'git pull origin main --allow-unrelated-histories'
Then you can push your changes to server using below command:
'git push -f origin main'

Push gitlab repository code to Google source repository

I followed below article to push gitlab repository code to Google cloud source repository but I'm getting an error on this command
git push -f google master
error: src refspec master does not match any.
error: failed to push some refs to 'https://source.developers.google.com/p/project/r/test/'
Article followed:
https://medium.com/#bamnet/cloud-source-repositories-gitlab-2fdcf1a8e50c
Is there anything , I'm doing wrong 😜? Any thoughts as to how I can avoid this error message?
src refspec master does not match any
The issue is the date of the article you are following: Aug. 2018.
GitLab Runner has changed since then, more precisely in May 2019.
The problem is described in this thread from May 2019:
Since we are using refspec to clone/fetch the repository, we checkout a specific commit and not checking out a specific branch.
When the script does git push master, the branch is nowhere to be found so git doesn’t know what to push.
That was because of, on GitLab side, MR 1203:
Basically, GitLab CE/EE sends refspecs parameter to GitLab Runner gitlab-org/gitlab-foss app/presenters/ci/build_runner_presenter.rb: this parameter is to used in GitLab Runners for fetching branch/tag refs from remote repository.
This change was introduced because we wanted GitLab Rails side to leverage respecs in order for issue 7380 "Combined ref pipelines (source+target branch)" though, there should not be a big difference between git clone $URL or mkdir $REPO_DIR && git remote add origin $URL && git fetch +refs/heads/branch_name:refs/remotes/origin/branch_name.
In fact, the new behavior has already run on our development project
https://gitlab.com/gitlab-org/gitlab-ce/pipelines and has no issues so far.
Issue 4097 was opened at the time
Workaround
Use HEAD when you want to push this to another remote.
deploy:
stage: deploy
script:
- git remote add heroku https://heroku:$HEROKU_API_KEY#git.heroku.com/<project>.git
- git push -f heroku HEAD:master
So don't push master. Push HEAD.
The OP Adam uses another workaround and add:
before_script:
- git checkout master

Unable to get all changed files details using GITLAB API

I have 29 changed files in one commit id and when I try to get all the details using below GitLab API then I am not getting all the files.
I am getting only 18 file details.
I tried with per_page=100&page=1 parameter but still not getting all changes.
GET /projects/:id/repository/commits/:sha/diff
Considering the GET /projects/:id/repository/commits/:sha/diff API is for getting the diff of a commit, check first locally (using git show --pretty) if you do see 29 or 18 files in the same commit present on your local cloned repo:
git show --compact-summary <SHA1>
If you don't see all the files there (meaning locally, not through GitLab) then some of some files were changed in other commits.

Github API generated annotated tag not showing up in git describe

I am trying to write a script to automatically setup github releases using a custom CI trigger. I have a python script that uses pygithub to automatically create a tag and a release.
# roughly the following code:
repo.create_git_tag(...)
repo.create_git_ref(...)
repo.create_git_release(...)
After running the script, everything shows up in the GitHub web UI, after a git fetch origin && git tag -l, I can see the tags locally. But when I use git describe (even with --tags), it fails with fatal: No tags can describe '<head_commit_hash>'
Using git show-ref --tags, I get something like the following:
hash1 refs/tags/releases/1.0.0
hash2 refs/tags/releases/1.1.0
hash3 refs/tags/releases/1.1.1
Then git cat-file -p hash1 gives me:
object hash_of_commit_at_tag
type commit
tag releases/1.0.0
tagger ...
Release: 1.0.0
But if I create and push the tag myself using git tag -a releases/1.0.0 hash_of_commit -m "Release 1.0.0", the git describe gives me the last reachable tag from my current HEAD.
Question is, is GitHub api or pygithub doing anything special? Or am I missing an api call in pygithub?
Apparently the GitHub API is creating un-annotated tags when you make a release.
The solution that works for me is to use git describe --tags
THis is from my repo with two tags created by making a release in the GitHub API
❯ git tag -l
v1.1.0
v1.2.0
❯ git describe
fatal: No annotated tags can describe '912268bd176bbda06983995894b46cf764b3e666'.
However, there were unannotated tags: try --tags.
❯ git describe --tags
v1.2.0

How can you reference a submodule in openshift

I've got an account with OpenShift which provides a git repository for each project you to work in. I've got one main project and two smaller projects resulting in a total of 3 git repositories.
I have just started to use the two smaller projects in the main project and seen that git can use the submodule command. I've added them both to the custom directory like so:
git submodule add ssh://...#app.rhcloud.com/~/git/app.git/
git submodule add ssh://...#api.rhcloud.com/~/git/api.git/
which has produced a directory structure like so:
node_modules
custom
app ------ full of tasty files
api ------ full of tasty files
index.js
.gitmodules
Within the .gitmodules file I have
[submodule "custom/api"]
path = custom/api
url = ssh://...#api.rhcloud.com/~/git/api.git/
[submodule "custom/app"]
path = custom/app
url = ssh://...#app.rhcloud.com/~/git/app.git/
Which is exactly what I want. It all works locally.
git add --all
git commit -m "new submodules"
git push
The issue is when I run the git push, it comes back with this error:
remote: Host key verification failed.
remote: fatal: Could not read from remote repository.
remote:
remote: Please make sure you have the correct access rights
remote: and the repository exists.
It looks like I need to add the ssh key of the main project to the two smaller projects so that I can ssh. Does anyone know how I can do this or have a better way of including submodules in OpenShift?
Thanks for the help in advance.
It looks like I need to add the ssh key of the main project to the two smaller projects so that I can ssh
At the parent (main) repo level, this shouldn't be the case: all the push does is to push the .gitmodules, and 2 gitlinks (special entries in the index) representing those 2 submodules.
It is more likely that the push doesn't find the proper .ssh/known_hosts, or the public/private ssh keys in order to push back to the app.rhcloud.com upstream repo: See "SSH connection problem with “Host key verification failed…” error" and "The authenticity of host can't be established".

Resources