I Want to search all our codebase in our Github installation for different text strings. We have app. 90 different repositories.
Is there such a method?
I can only find search for file names, authors etc., not search for strings inside code. My task is to find every project which uses or refers to systems, classes, methods etc. that soon are obsolete.
Alternately: Is there a method to download/clone all repositories in one action?
We use SourceTree as client software.
You can search directly at the top of an Organisation now. This results in the prefix org:.
e.g. if you wanted to search all twitter repos for the word bot you would search for org:twitter bot
https://github.com/search?l=&q=org%3Atwitter+bot&ref=advsearch&type=Code
You can search multiple repositories by adding the repo: option to your query, which you can see in action on GitHub's advanced search page. Each repo value takes the usual user/repository form. For example:
find_me repo:me/foo repo:you/bar repo:company/baz
To make a list of all your repositories if you don't have one, an easy way might be GitHub's repositories API.
Once you have the list, it would also be simple to clone everything with a simple shell script. I don't believe GitHub has a built-in feature for that.
while read repo; do
git clone https://github.com/$repo
done < list_of_repos.txt
Since it sounds like you're pulling an organization's repos, caniszczyk has a Gist doing just that. I'll copy the core of it here, but there's some discussion with updates and help for private repos.
curl -s https://api.github.com/orgs/twitter/repos?per_page=200 | \
ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
There's also another SO question asking about it, and a full backup script to get issues, wikis, etc.
Related
I am now building portfolio to get my first tech job. I would like for any recruiters/potential employers to see my code in case they want to see how I am putting things together but I don't want anyone to be able to fork or copy my work.
How is this possible?
If I have a private GitHub repo does that mean that you can see the repo but just not the inner contents? I have looked at the GitHub documentation already.
If I have a private GitHub repo does that mean that you can see the repo but just not the inner contents?
If you can access a repository (public or private), that means you can read its content and/or clone it (and read its content locally)
You would need to setup a private repository dedicated to show your file
names, meaning a collection of files with:
dummy content
the exact names and folder structure than your actual projects.
That way, you can share to select collaborator access to that "showcase" repository, without compromising the sensitive content of your actual project repositories.
A user proposed a localization to an open source project; however, they proposed a localization for an old version. I'd like to point them at the changes that were made between the two.
I know that I can show the difference between branches by providing the following link:
https://github.com/<user or organization>/<project>/master...master:<branch name>
Is there a similar interface for comparing certain commits? (and, ideally, only versions of a certain file) I'd like not to bother the potential contributor with learning git and doing the diff locally in the first place (although that I'll suggest that in the future).
I've tried
https://github.com/<user or organization>/<project>/master...master:<hash>
but that didn't work which is kinda expected; and I haven't found any reference on this matter either.
You can compare the difference between two commits on GitHub by using the below URL
https://github.com/{user}/{repo}/compare/{commit-1-hash}..{commit-2-hash}
For eg, to compare the diff between commits c3a414e and faf7c6f for the linguist repo of github, use the below
https://github.com/github/linguist/compare/c3a414e..faf7c6f
The above will show the diff like this:
You can go through the GitHub reference for more information.
I don't see a clean/obvious way to do this using the github api. So I'm not even sure it's really that easy/feasible to do. Am I forced to compute this locally (eg: query for ALL the commits of a given repo, and then tally them by author?)
If there is a clean 1-2 API call step way, instead of iterating over all the commits, that would be great.
It's not a duplicate, because the other question is asking how to do this with command line. I need to only use the github API because I will be going over 200+ repos and it needs to be fully programatic, as it starts from the list repos api.
Based on comment of Xavier Guihot, I add parameter for query
?q=contributions&order=desc
It become to
https://api.github.com/repos/scala/scala/contributors?q=contributions&order=desc
(You can use this extension https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa?hl=en , it help you easy to view result)
Upon brief Google and SO search, I couldn't find any info on this. I am looking at this Github repo which hasn't been updated for years, but there are many forks that are still being developed actively. Is there any way to search through commit messages from different forks of this Github repo network?
Beside the Google search already mentioned, another more precise alternative, if that repo is not too big, is to:
list all the forks with this API GET /repos/:owner/:repo/forks
clone them, and do a git grep in each of those local clones.
That way, you are sure to have a complete search.
See also the python frost-nzcr4/find_forks script.
View the Developer Tools while you're loading the repo network page. In the log you'll notice there's two urls - "meta" and "chunk".
Meta is the (json) list of all the users who are in the network and various properties needed to draw the graph, and "chunk" is the commit log from all the users in the graph, which is used to render the tooltips that come up.
Save these outputs and use your favourite text editor / command line tool to search the commit messages.
[[Please note that Github has changed a lot since this question was first asked; instead of "download page" read "new release".]]
I generate PDF documentation as part of my projects and I'd like them to stay in sync with my Git repository (it's not always possible for people to build their own since they often use proprietary fonts).
However, it's not really "correct" to add the PDFs to the repository since it's a derived file; furthermore, doing this adds significantly to the size of the commits and the size of the repository overall.
Is it possible to programmatically send files to the GitHub download page? (I know that tagged commits are automatically added there with git push --tags but I don't know where this is documented. I suppose I could do something fancy by adding a separate branch only containing the PDFs themselves — as done by the GitHub user pages — but I'm a bit rusty on using Git this way.)
Github API v3 supports this feature.
GitHub also provides a maven plugin based on the java API that is part of the Eclipse Mylyn connector for GitHub.
There is a ruby gem called github_api.
The other answer talks about net-github-upload which is available for perl and ruby.
check out for net-github-upload which is available
for perl: http://github.com/typester/net-github-upload-perl
and ruby: http://github.com/Constellation/ruby-net-github-upload
With that you can write a small script to upload and update your PDF easily. To sad there's no easy way provided by github guys themselves..
cheer!
The GitHub blog post announcing that this feature has been disabled: https://github.com/blog/1302-goodbye-uploads
I take it that by "GitHub download page", the owner means a repo–more specifically a branch– that can be downloaded via the "download" button.
If you want to add a file to a repo using the API, you will have to become familiar with the process described here: https://developer.github.com/v3/git/
It's not the easiest process in the world, but mastering it will force you to understand the concepts of blobs, trees, commits and references, amongst others.
You can't just "send a file" to a repo because you're working with Git, and Git has some "internal expectations" that you just can't ignore (it's impossible to think of GitHub as some sort of host that you can ftp). Explaining the flow required to create a file in a GitHub repo is certainly beyond the scope of the original question, but to provide a clear answer: no, it's not possible to programmatically upload a file on GitHub, but yes it is possible to programmatically push a file on GitHub".
There's a PHP library named GitHubTreePHP that lets you automate the process (Disclaimer: I wrote it).