git.cweiske.de
/
phorkie.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
automatically add file extension to new files when it has no extension
[phorkie.git]
/
src
/
phorkie
/
Repository
/
Post.php
diff --git
a/src/phorkie/Repository/Post.php
b/src/phorkie/Repository/Post.php
index 828dbadb16e897c8c36833b4d9a82cd968cc7778..b9d9be5aa626e6af73ca4556e2debc6481f66196 100644
(file)
--- a/
src/phorkie/Repository/Post.php
+++ b/
src/phorkie/Repository/Post.php
@@
-44,13
+44,20
@@
class Repository_Post
}
$bNew = false;
}
$bNew = false;
+ $bDelete = false;
if (!isset($orignalName) || $orignalName == '') {
//new file
$bNew = true;
if (!isset($orignalName) || $orignalName == '') {
//new file
$bNew = true;
+ if (strpos($name, '.') === false) {
+ //automatically append file extension if none is there
+ $name .= '.' . $arFile['type'];
+ }
} else if (!$this->repo->hasFile($orignalName)) {
//unknown file
//FIXME: Show error message
continue;
} else if (!$this->repo->hasFile($orignalName)) {
//unknown file
//FIXME: Show error message
continue;
+ } else if (isset($arFile['delete']) && $arFile['delete'] == 1) {
+ $bDelete = true;
} else if ($orignalName != $name) {
//FIXME: what to do with overwrites?
$vc->getCommand('mv')
} else if ($orignalName != $name) {
//FIXME: what to do with overwrites?
$vc->getCommand('mv')
@@
-61,7
+68,12
@@
class Repository_Post
}
$file = $this->repo->getFileByName($name, false);
}
$file = $this->repo->getFileByName($name, false);
- if ($bNew || $file->getContent() != $arFile['content']) {
+ if ($bDelete) {
+ $command = $vc->getCommand('rm')
+ ->addArgument($file->getFilename())
+ ->execute();
+ $bChanged = true;
+ } else if ($bNew || $file->getContent() != $arFile['content']) {
file_put_contents($file->getPath(), $arFile['content']);
$command = $vc->getCommand('add')
->addArgument($file->getFilename())
file_put_contents($file->getPath(), $arFile['content']);
$command = $vc->getCommand('add')
->addArgument($file->getFilename())