Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Eric Rasmussen
UNL-CMS
Commits
4b28bcca
Commit
4b28bcca
authored
Mar 29, 2013
by
Eric Rasmussen
Browse files
[gh-631] Working clone and pull with Run operation
parent
74faafd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
sites/all/modules/git_include/git_include.module
View file @
4b28bcca
...
...
@@ -127,7 +127,7 @@ function git_include_admin_settings_form() {
*/
function
git_include
(
$name
)
{
if
(
!
$repo
=
git_include_load
(
$name
))
{
throw
new
Exception
(
t
(
'
Git include r
epository not found: @name'
,
array
(
'@name'
=>
$name
)));
throw
new
Exception
(
t
(
'
R
epository
info
not found: @name'
,
array
(
'@name'
=>
$name
)));
}
$dir
=
variable_get
(
'git_include_dir'
,
'public://git_include'
);
...
...
@@ -137,8 +137,19 @@ function git_include($name) {
throw
new
Exception
(
t
(
'Error resolving directory: @dir'
,
array
(
'@dir'
=>
$dir
)));
}
$command
=
'git clone '
.
$repo
->
options
[
'source_repo'
]
.
' '
.
$realpath
.
'/'
.
$repo
->
name
;
//$result = exec($command, $output, $return_var);
$command
=
'cd '
.
$realpath
.
'/'
.
$repo
->
name
.
'; git rev-parse --show-toplevel;'
;
$git_path
=
exec
(
$command
,
$output
,
$return_var
);
$repopath
=
$realpath
.
'/'
.
$repo
->
name
;
if
(
strtolower
(
$git_path
)
!==
strtolower
(
$repopath
))
{
$operation
=
'clone'
;
$command
=
'git clone '
.
$repo
->
options
[
'source_repo'
]
.
' '
.
$repopath
;
}
else
{
$operation
=
'pull'
;
$command
=
'cd '
.
$repopath
.
'; git pull;'
;
}
ob_start
();
passthru
(
$command
,
$return_var
);
...
...
@@ -147,11 +158,11 @@ function git_include($name) {
drupal_set_message
(
$result
,
'git_include'
);
if
(
$return_var
!==
0
)
{
if
(
!
is_int
(
$return_var
)
||
$return_var
!==
0
)
{
throw
new
Exception
(
t
(
'Shell command returned with status @status: @command'
,
array
(
'@command'
=>
$command
,
'@status'
=>
$return_var
)));
}
else
{
drupal_set_message
(
'Success!'
,
'status'
);
drupal_set_message
(
t
(
'Git @op completed for @repo'
,
array
(
'@op'
=>
$operation
,
'@repo'
=>
$repo
->
options
[
'label'
]))
,
'status'
);
}
return
$result
;
...
...
sites/all/modules/git_include/plugins/export_ui/git_include_export_ui.class.php
View file @
4b28bcca
...
...
@@ -98,6 +98,7 @@ class git_include_export_ui extends ctools_export_ui {
*/
function
run_page
(
$js
,
$input
,
$item
)
{
watchdog
(
'git_include'
,
'Running '
.
$item
->
name
);
try
{
git_include
(
$item
->
name
);
$input
[
'test_result'
]
=
theme_status_messages
(
array
(
'display'
=>
NULL
));
...
...
@@ -107,6 +108,7 @@ class git_include_export_ui extends ctools_export_ui {
watchdog_exception
(
'git_include'
,
$e
);
$input
[
'test_result'
]
=
theme_status_messages
(
array
(
'display'
=>
NULL
));
}
watchdog
(
'git_include'
,
'Finished running '
.
$item
->
name
);
if
(
!
$js
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment