How do I create a "Revision page" with the GitHub API? - github

I would like to create a "Revision page" where the people can see on what I've been working using GitHub there's an example about what I mean:
It is supposed to show the commits from my GitHub repository.

A) More information is required
Firstly, could you clarify if it is your intention to
Show the Commit history for a single repository, or
You wish to show your commit activity across multiple repositories
Also:
You wish to have this information displayed on Github, or
You
wish to have this information displayed on an external site.
B) Displaying information on GitHub
If the intention is a combination of 1 and 3, then my first suggestion would be to check the existing functionality of GitHub, which has such a feature built-in.
This can be accessed by navigating to your repository, and simply clicking the Commits button. An example of the results can be found here:
Example GitHub Commit History
C) Displaying information on an external site
As you mention that you have limited experience with PHP, I would certainly start by evaluating GitList:
GitList allows you to browse repositories using your favorite browser,
viewing files under different revisions, commit history and diffs.
GitList is free and open source software, written in PHP, on top of
Silex and the Twig template engine.
If you feel confident that you could create your own solution to display the information in an external web page, then you should begin by familiarising yourself with the GitHub Developer Documentation, and specifically:
List commits on a repository
It is also worth examining the following article and existing GitHub project in order to enhance your knowledge:
How to Use Github’s API with PHP (SitePòint Article with code)
GitHub PHP Client (GitHub Project)
It may be that you can clone one of these projects, strip it down to the features essential for your needs, and customise the UI.

Related

How to Automatically Generate Documentation for ReadMe's from Multiple Repositories

I want to automatically generate a documentation site that contains the ReadMe's from all the repositories within my project. I am a little new to GitHub, so I'm not sure if my terminology is correct. I provide the link to the GitHub page that has all of the repositories.
https://github.com/casework
I was wondering if there is any way to have a website that automatically generates documentation for all the ReadMe's found in any of the repositories. Ideally, this would be a website that recognizes if the ReadMe's were edited or if a new repository was made, and then automatically update the documentation for the website.
I have been looking at mkdocs and Sphinx, but I was wondering if there was an easy way to automatically generate and update documentation based on the ReadMe's from these repositories. As far as I know, these tools would not automatically update the website.

Can you search github network commit messages?

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.

Make Jira links clickable in Github

Is there a way I can make Jira ticket id's on Github link to Jira? (much the same way as how it happens on Bitbucket).
Maybe there is a plugin or something I could use ?
EDIT:
I specifically want ticket id's in Github to link through to Jira, this is not described in any of the resources below:
How do I connect github to JIRA?
https://confluence.atlassian.com/display/BITBUCKET/Linking+Bitbucket+and+GitHub+accounts+to+JIRA
https://help.github.com/articles/integrating-jira-with-your-projects/
Update 2022:
Dusan Plavak mentions in the comments that, as of today (Q1 2022), you can also import / automate creation of autolinks via github api.
You can also use gh api:
gh api repos/octocat/hello-world/autolinks \
-f -q 'key_prefix:key_prefix url_template:url_template'
And since July 2022, you also have autolinks with alphanumeric IDs (for instance for a Trello card URL: https://trello.com/c/3eZr2Bxw).
2019: No need for Chrome plugin, Safari hack or scripts.
From October 2019, GitHub can automatically transform TICKET references to Jira links, for example.
See "Save time linking resources with autolink references" from Lars Schneider.
Now you can set up an autolink reference and GitHub will automatically create links (to external systems) for you.
How it works
If you use GitHub with external services (like Jira), you might be familiar with shorthand references (like TICKET-123) to point to resources in those external systems.
Starting today, GitHub can automatically transform shorthand references into clickable links for GitHub Pro, Team, and Enterprise plans.
So not the regular github.com.
To enable this feature, a repository admin needs to register the reference prefix (such as TICKET-) in the settings.
Afterwards, references of that type are detected in issues, pull requests, comments, or commit messages, and turned into links.
This speeds up navigation between GitHub and external systems.
See documentation.
Note that the ticket prefix is not included in the hyperlink despite being included in the anchor text. The URL preview in the setting is accurate:
The animation in the feature announcement, replicated above, shows this limitation but not clearly.
This means that you have to either include the project key in the target URL as well or prefix all project keys with a another key and use that as the autolink prefix.
You cannot even use Git's trailers to reference tickets and use autolinks, because trailers are key-value pairs separated by : (colon space) and an autolink prefix that ends with a space is invalid.
I decided to make a Chrome extension for this ! This extension works on all websites, not just Jira ! :D
Install it here:
https://chrome.google.com/webstore/detail/jira-hotlinker/lbifpcpomdegljfpfhgfcjdabbeallhk
Source code:
https://github.com/helmus/Jira-Hot-Linker
If you mean the commit message for commit e0d9e32 shows TEST-1234 Fixed this really bad bug and you want TEST-1234 to link to http://www.your-jira.com/browse/TEST-1234 then no it does not look like this is possible.
You could look to do a Chrome/Firefox browser plugin that accomplishes the behavior you desire. (Scans the webpage looking in certain sections for JIRA Key's and then updates them to links)
I wrote a site specific Safari hack. It requires you to install it yourself, but that gives you the opportunity to read the code (it's short!) first. https://github.com/unicode-org/icu-jira-safari
it fetches elements of class commit, gh-header-title, and js-issue-row with getElementsByClassName()
then, for anything such as ICU-1234 (our Jira project id), it creates a link to the appropriate URL on the Jira server.
I wanted to include Jira issue status as well, but Atlassian Cloud CORS settings prevent that.
Here is an example if the linkification (ICU-10464 turns into a link on the right hand side).
Someone made exactly what I wanted coming from gitlab.
https://chrome.google.com/webstore/detail/linkify-jira-issues/ekbbnaokafbanjgmcbllligemhiclbcb
This updates the text in my github PRs to convert them in clickable links.
I made a super simple Chrome extension for this. It simply adds a link to the relevant JIRA ticket on your Github pull request page in a non-obtrusive way (See screenshot below)
Install it here: https://chrome.google.com/webstore/detail/github-to-jira/dhnagjladcclacjnccpnibdmkljidnhl?hl=en-GB
Source code here: https://github.com/mfalade/github-to-jira
While Github Autolink is an awesome solution, this is easier to use for the following reasons.
You don't need to provide a description with ticket number for this to work. It automatically derives ticket number from your branch name.
You don't have to configure anything on the Github admin page. Perfect for users who don't have admin privileges
You can work on multiple projects or teams more easily. Supports multiple ticket prefixes.
This extension works for all project management tools you might want to link to

GitHub tool to review post commits?

I am looking for a GitHub PostCommit CodeReview tool which does the following:
Looking specifically for PostCommit CodeReview
Has LDap support
Displays git branches and files.
Select text and add comment. (like Google Doc)
Email all comments with selected snippet to user.
If you want a full web interface, you could go for something like Github Enterprise or Gitlab. Both really helpful applications for anything Git. You can basicly do the things you want in there. You can get an easy file browser of the repository, and add comments on specific lines of code.

Programmatically add files to a GitHub download page

[[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).