-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Added check for if git exists #5444
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,11 @@ | |
exit; | ||
} | ||
|
||
$git_found = check_git_exists(); | ||
if ($git_found !== true) { | ||
print_warn('Unable to locate git. This should probably be installed.'); | ||
} | ||
|
||
$versions = version_info(); | ||
$cur_sha = $versions['local_sha']; | ||
|
||
|
@@ -103,9 +108,11 @@ | |
print_fail('You need to run this script as root' . (isset($config['user']) ? ' or '.$config['user'] : '')); | ||
} | ||
|
||
if ($config['update_channel'] == 'master' && $cur_sha != $versions['github']['sha']) { | ||
$commit_date = new DateTime('@'.$versions['local_date'], new DateTimeZone(date_default_timezone_get())); | ||
print_warn("Your install is out of date, last update: " . $commit_date->format('r')); | ||
if ($git_found === true) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. === is better, it's more explicit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, as long as we are doing it purposefully, you are the master of the php code ;) |
||
if ($config['update_channel'] == 'master' && $cur_sha != $versions['github']['sha']) { | ||
$commit_date = new DateTime('@'.$versions['local_date'], new DateTimeZone(date_default_timezone_get())); | ||
print_warn("Your install is out of date, last update: " . $commit_date->format('r')); | ||
} | ||
} | ||
|
||
// Check php modules we use to make sure they are loaded | ||
|
@@ -252,21 +259,22 @@ | |
print_list($devices, "\t %s\n"); | ||
} | ||
|
||
if ($versions['local_branch'] != 'master') { | ||
print_warn("Your local git branch is not master, this will prevent automatic updates."); | ||
} | ||
if ($git_found === true) { | ||
if ($versions['local_branch'] != 'master') { | ||
print_warn("Your local git branch is not master, this will prevent automatic updates."); | ||
} | ||
|
||
// check for modified files | ||
$modifiedcmd = 'git diff --name-only --exit-code'; | ||
if ($username === 'root') { | ||
$modifiedcmd = 'su '.$config['user'].' -c "'.$modifiedcmd.'"'; | ||
} | ||
exec($modifiedcmd, $cmdoutput, $code); | ||
if ($code !== 0 && !empty($cmdoutput)) { | ||
print_warn("Your local git contains modified files, this could prevent automatic updates.\nModified files:"); | ||
print_list($cmdoutput, "\t %s\n"); | ||
// check for modified files | ||
$modifiedcmd = 'git diff --name-only --exit-code'; | ||
if ($username === 'root') { | ||
$modifiedcmd = 'su '.$config['user'].' -c "'.$modifiedcmd.'"'; | ||
} | ||
exec($modifiedcmd, $cmdoutput, $code); | ||
if ($code !== 0 && !empty($cmdoutput)) { | ||
print_warn("Your local git contains modified files, this could prevent automatic updates.\nModified files:"); | ||
print_list($cmdoutput, "\t %s\n"); | ||
} | ||
} | ||
|
||
// Modules test | ||
$modules = explode(',', $options['m']); | ||
foreach ($modules as $module) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you use
if (!$git_found){
instead?