Я сделал php-скрипт для экспорта измененных файлов в Windows. Если у вас есть сервер разработки localhost с настройкой php, вы можете легко запустить его. Он будет помнить ваш последний репозиторий и всегда экспортировать его в одну и ту же папку. Перед экспортом папка экспорта всегда очищается. Вы также увидите удаленные файлы в красном цвете, чтобы знать, что нужно удалить на сервере.
Это всего лишь два файла, поэтому я отправлю их здесь. Предположим, что ваши репозитории расположены в каталоге c: / www в своих папках и что http: // localhost также указывает на c: / www и поддерживает php. Положим эти 2 файла в c: / www / git-export -
index.php:
0) {
mkdir($dir, $perm);
}
}
}
/* deletes dir recursevely, be careful! */
function deleteDirRecursive($f) {
if (strpos($f, "c:/www/export" . "/") !== 0) {
exit("deleteDirRecursive() protection disabled deleting of tree: $f - please edit the path check in source php file!");
}
if (is_dir($f)) {
foreach(scandir($f) as $item) {
if ($item == '.' || $item == '..') {
continue;
}
deleteDirRecursive($f . "/" . $item);
}
rmdir($f);
} elseif (is_file($f)) {
unlink($f);
}
}
$lastRepoDirFile = "last_repo_dir.txt";
$repo = isset($_POST['repo']) ? $_POST['repo'] : null;
if (!$repo && is_file($lastRepoDirFile)) {
$repo = file_get_contents($lastRepoDirFile);
}
$range = isset($_POST['range']) ? $_POST['range'] : "HEAD~1 HEAD";
$ini = parse_ini_file("git-export.ini");
$exportDir = $ini['export_dir'];
?>
Git export changed files
source repository: $repoDir
";
echo "exporting to: $exportDir
\n";
createDir($exportDir);
// empty export dir
foreach (scandir($exportDir) as $file) {
if ($file != '..' && $file != '.') {
deleteDirRecursive("$exportDir/$file");
}
}
// execute git diff
$cmd = "git --git-dir=$repoDir/.git diff $range --name-only";
exec("$cmd 2>&1", $output, $err);
if ($err) {
echo "Command error:
";
echo implode("
", array_map('htmlspecialchars', $output));
exit;
}
// $output contains a list of filenames with paths of changed files
foreach ($output as $file) {
$source = "$repoDir/$file";
if (is_file($source)) {
if (strpos($file, '/')) {
createDir("$exportDir/" .dirname($file));
}
copy($source, "$exportDir/$file");
echo "$file
\n";
} else {
// deleted file
echo "$file
\n";
}
}
}
?>
git-export.ini:
; path to all your git repositories for convenience - less typing
base_repo_dir = c:/www
; if you change it you have to also change it in the php script
; in deleteDirRecursive() function - this is for security
export_dir = c:/www/export
Теперь загрузите localhost / git-export / в браузере. Сценарий настроен для экспорта всегда в c: / www / export - изменение всех путей в соответствии с вашей средой или изменение сценария в соответствии с вашими потребностями.
Это будет работать, если вы установили Git так, чтобы git в вашем PATH - это можно настроить при запуске установщика Windows Git.
С помощью Хатенева я нашел следующее решение:
$obj = С помощью Хатенева я нашел следующее решение:
[110] $ obj = $ _POST ['data'] даст вам строку: question1 = Yes & amp; question2 = No
[ 114] parse_str () проанализирует строку в переменных. И теперь его можно использовать в моем php-файле http://www.php.net/manual/en/function.parse-str.php
tnx community для быстрой помощи и разработки. ответ!
POST['data'];
parse_str($obj, $output);
$question1 = $output['question1'];
$ obj = $ _POST ['data'] даст вам строку: question1 = Yes & amp; question2 = No
[ 114] parse_str () проанализирует строку в переменных. И теперь его можно использовать в моем php-файле http://www.php.net/manual/en/function.parse-str.php
tnx community для быстрой помощи и разработки. ответ!