Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ssh git links to be used. #89

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def shorten_commit_link(commit)
url = (url || '').sub(%r{^http://}, 'git://')
commit ||= nil

if url =~ %r{github\.com/([^/]+)/([^/]+)}
if url =~ %r{github\.com[/:]([^/]+)/([^/]+)}
username, project = $1, $2
if settings.whitelisted_projects.include?("#{username}/#{project}")
puts "Dropping safe mode for #{username}/#{project}"
Expand Down
3 changes: 2 additions & 1 deletion lib/scm_checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def initialize(app, url, commit = nil)
case url
when Array
self.username, self.project = *url
when %r{^(?:https?|git)://(?:www\.?)?github\.com/([^/]+)/([^/]+?)(?:\.git)?/?$}
when %r{^(?:https?|git)://(?:www\.?)?github\.com/([^/]+)/([^/]+?)(?:\.git)?/?$},
%r{^git@github\.com:([^/]+)/([^/]+?)(?:\.git)?/?$}
self.username, self.project = $1, $2
else
raise InvalidSchemeError
Expand Down
2 changes: 1 addition & 1 deletion public/js/project_checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function checkoutForm() {
if (data == "OK") {
var arr = url.split('/');
var dirname = arr[arr.length-1].replace(/\.[^.]+$/, '');
var match = url.match(/^(?:git|https?):\/\/(?:www\.)?github\.com\/([^\/]+)/);
var match = url.match(/^(?:git:\/\/|https:\/\/|git@?)(?:www\.)?github\.com[\/|:]([^\/]+)|(?:git@)github\.com[\/:]([^\/]+)/);
if (match) {
var name = match[1];
dirname = name + '/' + dirname + '/' +
Expand Down
7 changes: 7 additions & 0 deletions spec/github_checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ def git(url, commit = nil)
end
end

it "should accept ssh style github urls" do
git("git@github.com:reevoo/stratocumulus.git")
@git.username.should == "reevoo"
@git.project.should == "stratocumulus"
@git.name.should == "reevoo/stratocumulus"
end

it "should accept github URLs with ending in .git" do
git("git://github.com/lsegal/yard.git")
@git.username.should == "lsegal"
Expand Down
4 changes: 2 additions & 2 deletions templates/checkout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
</style>
<div id="checkout">
<h2>Add your own project</h2>
<small class="example">(eg. git://github.com/lsegal/yard.git)</small>
<small class="example">(eg. https://github.com/lsegal/yard.git)</small>
<form id="checkout_form" action="/checkout" method="post">
<input class="url" type="text" id="url" name="url" placeholder="git://github.com/username/project" />
<input class="url" type="text" id="url" name="url" placeholder="https://github.com/username/project" />
<div class="loadicon"></div>
<input type="hidden" id="scheme" name="scheme" value="git" />
<br/>
Expand Down
2 changes: 1 addition & 1 deletion templates/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
function reloadProject() {
$('.libraries .project_reload').click(function() {
var proj = $(this).parent().find('a:first-child').text();
$('#url').val("git://github.com/" + proj);
$('#url').val("https://github.com/" + proj);
$('#commit').val('');
$('#checkout_form').submit();
$(this).find('img').attr('src', '/images/loading.gif');
Expand Down
2 changes: 1 addition & 1 deletion templates/scm_404.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<p>We haven't generated any docs for <strong><%= h @username %>/<%= h @project %></strong>. You can add the project yourself by entering the GitHub project information below.
You can also see a list of available projects <a href="/github">here</a>.</p>
<script type="text/javascript" charset="utf-8">
$(function() { $('#url').val('git://github.com/<%= h @username %>/<%= h @project %>'); });
$(function() { $('#url').val('https://github.com/<%= h @username %>/<%= h @project %>'); });
</script>

<%= erb :checkout, :layout => false %>
Expand Down