<form method="post" action="/fork-remote" enctype="multipart/form-data" class="well form-inline form-horizontal">
+ <input type="hidden" name="orig_url" value="{{remote_url}}" />
<div class="control-group">
<p>
The URL you provided contains links to several Git repositories.
public function parse()
{
- $arUrl = parse_url($this->url);
+ $arUrl = parse_url($this->url);
$scheme = $arUrl['scheme'] ?: '';
+
if ($scheme == 'https' && isset($arUrl['host'])
&& $arUrl['host'] == 'gist.github.com'
) {
- $scheme = 'git';
- $this->url = 'git://gist.github.com/'. ltrim($arUrl['path'], '/') . '.git';
+ $this->arGitUrls[][] = 'git://gist.github.com/'
+ . ltrim($arUrl['path'], '/') . '.git';
+ return true;
}
switch ($scheme) {
return $this->arGitUrls;
}
+ /**
+ * Get the URL from which the git URL was derived, often
+ * the HTTP URL.
+ *
+ * @return string
+ */
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+ public function setUrl($url)
+ {
+ $this->url = $url;
+ }
+
public function isSupported($url)
{
return parse_url($url, PHP_URL_SCHEME) == 'git';
return $new;
}
- public function forkRemote($url)
+ public function forkRemote($cloneUrl, $originalUrl)
{
- $new = $this->fork($url);
+ $new = $this->fork($cloneUrl);
file_put_contents(
$new->gitDir . '/description',
- 'Fork of ' . $url
+ 'Fork of ' . $originalUrl
);
return $new;
}
//no url found
$error = 'No git:// clone URL found';
} else if (false !== ($gitUrl = $fr->getUniqueGitUrl())) {
+ if (isset($_POST['orig_url'])) {
+ $fr->setUrl($_POST['orig_url']);
+ }
$forker = new Forker();
- $new = $forker->forkRemote($gitUrl);
+ $new = $forker->forkRemote($gitUrl, $fr->getUrl());
redirect($new->getLink('display'));
} else {
//multiple urls found