git.cweiske.de
/
phorkie.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
813d3f5
)
remote forking: use the original http/https url in description
author
Christian Weiske
<cweiske@cweiske.de>
Fri, 21 Sep 2012 18:10:41 +0000
(20:10 +0200)
committer
Christian Weiske
<cweiske@cweiske.de>
Fri, 21 Sep 2012 18:10:41 +0000
(20:10 +0200)
data/templates/fork-remote-multiple.htm
patch
|
blob
|
history
src/phorkie/ForkRemote.php
patch
|
blob
|
history
src/phorkie/Forker.php
patch
|
blob
|
history
www/fork-remote.php
patch
|
blob
|
history
diff --git
a/data/templates/fork-remote-multiple.htm
b/data/templates/fork-remote-multiple.htm
index f5a95b23bbf533e0ded816f3cce71f8766dfd768..8709f11902e06d40088b5ecc3bf345cb328e710a 100644
(file)
--- a/
data/templates/fork-remote-multiple.htm
+++ b/
data/templates/fork-remote-multiple.htm
@@
-1,4
+1,5
@@
<form method="post" action="/fork-remote" enctype="multipart/form-data" class="well form-inline form-horizontal">
<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.
<div class="control-group">
<p>
The URL you provided contains links to several Git repositories.
diff --git
a/src/phorkie/ForkRemote.php
b/src/phorkie/ForkRemote.php
index c9ed748ad189f7f841cc2e6e96255e48f3d47b59..d2b077be06b7762219141a3ecaadf0ffe90150bf 100644
(file)
--- a/
src/phorkie/ForkRemote.php
+++ b/
src/phorkie/ForkRemote.php
@@
-22,13
+22,15
@@
class ForkRemote
public function parse()
{
public function parse()
{
- $arUrl = parse_url($this->url);
+ $arUrl
= parse_url($this->url);
$scheme = $arUrl['scheme'] ?: '';
$scheme = $arUrl['scheme'] ?: '';
+
if ($scheme == 'https' && isset($arUrl['host'])
&& $arUrl['host'] == 'gist.github.com'
) {
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) {
}
switch ($scheme) {
@@
-113,6
+115,22
@@
class ForkRemote
return $this->arGitUrls;
}
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';
public function isSupported($url)
{
return parse_url($url, PHP_URL_SCHEME) == 'git';
diff --git
a/src/phorkie/Forker.php
b/src/phorkie/Forker.php
index 3425a72283eefaa2f758301be6863bc8e155a178..f4901ed9251e4720e54e7251518c3ceca2eb22d7 100644
(file)
--- a/
src/phorkie/Forker.php
+++ b/
src/phorkie/Forker.php
@@
-10,12
+10,12
@@
class Forker
return $new;
}
return $new;
}
- public function forkRemote($
u
rl)
+ public function forkRemote($
cloneUrl, $originalU
rl)
{
{
- $new = $this->fork($
u
rl);
+ $new = $this->fork($
cloneU
rl);
file_put_contents(
$new->gitDir . '/description',
file_put_contents(
$new->gitDir . '/description',
- 'Fork of ' . $
u
rl
+ 'Fork of ' . $
originalU
rl
);
return $new;
}
);
return $new;
}
diff --git
a/www/fork-remote.php
b/www/fork-remote.php
index 374c8b89ab8e4105009e97dffae577b54c0515db..05677485e4156a5066dbf69842cd1f8750a6ed73 100644
(file)
--- a/
www/fork-remote.php
+++ b/
www/fork-remote.php
@@
-14,8
+14,11
@@
if (isset($_POST['remote_url'])) {
//no url found
$error = 'No git:// clone URL found';
} else if (false !== ($gitUrl = $fr->getUniqueGitUrl())) {
//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();
$forker = new Forker();
- $new = $forker->forkRemote($gitUrl);
+ $new = $forker->forkRemote($gitUrl
, $fr->getUrl()
);
redirect($new->getLink('display'));
} else {
//multiple urls found
redirect($new->getLink('display'));
} else {
//multiple urls found