Completed
Pull Request — master (#489)
by Helpful
03:34
created
code/form/TabbedSelectionGroup.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,23 +3,23 @@
 block discarded – undo
3 3
 class TabbedSelectionGroup extends SelectionGroup
4 4
 {
5 5
 
6
-    /**
7
-     * @return ArrayList
8
-     */
9
-    public function FieldList()
10
-    {
11
-        $items = CompositeField::FieldList()->toArray();
12
-        $fields = new ArrayList();
6
+	/**
7
+	 * @return ArrayList
8
+	 */
9
+	public function FieldList()
10
+	{
11
+		$items = CompositeField::FieldList()->toArray();
12
+		$fields = new ArrayList();
13 13
 
14
-        foreach ($items as $item) {
15
-            $extra = array(
16
-                'Selected' => $this->value == $item->getValue(),
17
-            );
14
+		foreach ($items as $item) {
15
+			$extra = array(
16
+				'Selected' => $this->value == $item->getValue(),
17
+			);
18 18
 
19
-            $item = $item->customise($extra);
20
-            $fields->push($item);
21
-        }
19
+			$item = $item->customise($extra);
20
+			$fields->push($item);
21
+		}
22 22
 
23
-        return $fields;
24
-    }
23
+		return $fields;
24
+	}
25 25
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
         $items = CompositeField::FieldList()->toArray();
12 12
         $fields = new ArrayList();
13 13
 
14
-        foreach ($items as $item) {
14
+        foreach($items as $item) {
15 15
             $extra = array(
16 16
                 'Selected' => $this->value == $item->getValue(),
17 17
             );
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,13 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-class TabbedSelectionGroup extends SelectionGroup
4
-{
3
+class TabbedSelectionGroup extends SelectionGroup {
5 4
 
6 5
     /**
7 6
      * @return ArrayList
8 7
      */
9
-    public function FieldList()
10
-    {
8
+    public function FieldList() {
11 9
         $items = CompositeField::FieldList()->toArray();
12 10
         $fields = new ArrayList();
13 11
 
Please login to merge, or discard this patch.
code/jobs/CreateEnvJob.php 3 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -2,75 +2,75 @@
 block discarded – undo
2 2
 class CreateEnvJob
3 3
 {
4 4
 
5
-    /**
6
-     *
7
-     * @var array
8
-     */
9
-    public $args;
5
+	/**
6
+	 *
7
+	 * @var array
8
+	 */
9
+	public $args;
10 10
 
11
-    /**
12
-     *
13
-     */
14
-    public function setUp()
15
-    {
16
-        $this->updateStatus('Started');
17
-        chdir(BASE_PATH);
18
-    }
11
+	/**
12
+	 *
13
+	 */
14
+	public function setUp()
15
+	{
16
+		$this->updateStatus('Started');
17
+		chdir(BASE_PATH);
18
+	}
19 19
 
20
-    /**
21
-     *
22
-     * @global array $databaseConfig
23
-     */
24
-    public function tearDown()
25
-    {
26
-        $this->updateStatus('Finished');
27
-        chdir(BASE_PATH);
28
-    }
20
+	/**
21
+	 *
22
+	 * @global array $databaseConfig
23
+	 */
24
+	public function tearDown()
25
+	{
26
+		$this->updateStatus('Finished');
27
+		chdir(BASE_PATH);
28
+	}
29 29
 
30
-    /**
31
-     *
32
-     */
33
-    public function perform()
34
-    {
35
-        echo "[-] CreateEnvJob starting" . PHP_EOL;
36
-        // This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque
37
-        try {
38
-            $envCreate = DNCreateEnvironment::get()->byId($this->args['createID']);
39
-            if (!($envCreate && $envCreate->exists())) {
40
-                throw new RuntimeException(sprintf('Could not find create environment record %s', $args['createID']));
41
-            }
30
+	/**
31
+	 *
32
+	 */
33
+	public function perform()
34
+	{
35
+		echo "[-] CreateEnvJob starting" . PHP_EOL;
36
+		// This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque
37
+		try {
38
+			$envCreate = DNCreateEnvironment::get()->byId($this->args['createID']);
39
+			if (!($envCreate && $envCreate->exists())) {
40
+				throw new RuntimeException(sprintf('Could not find create environment record %s', $args['createID']));
41
+			}
42 42
 
43
-            // This will throw and exception if it fails.
44
-            $envCreate->createEnvironment();
45
-        } catch (Exception $e) {
46
-            $this->updateStatus('Failed');
47
-            echo "[-] CreateEnvJob failed" . PHP_EOL;
48
-            throw $e;
49
-        }
50
-        echo "[-] CreateEnvJob finished" . PHP_EOL;
51
-    }
43
+			// This will throw and exception if it fails.
44
+			$envCreate->createEnvironment();
45
+		} catch (Exception $e) {
46
+			$this->updateStatus('Failed');
47
+			echo "[-] CreateEnvJob failed" . PHP_EOL;
48
+			throw $e;
49
+		}
50
+		echo "[-] CreateEnvJob finished" . PHP_EOL;
51
+	}
52 52
 
53
-    /**
54
-     *
55
-     * @param string $status
56
-     * @global array $databaseConfig
57
-     */
58
-    protected function updateStatus($status)
59
-    {
60
-        global $databaseConfig;
61
-        DB::connect($databaseConfig);
53
+	/**
54
+	 *
55
+	 * @param string $status
56
+	 * @global array $databaseConfig
57
+	 */
58
+	protected function updateStatus($status)
59
+	{
60
+		global $databaseConfig;
61
+		DB::connect($databaseConfig);
62 62
 
63
-        $record = DNCreateEnvironment::get()->byID($this->args['createID']);
64
-        $record->Status = $status;
65
-        $record->write();
66
-    }
63
+		$record = DNCreateEnvironment::get()->byID($this->args['createID']);
64
+		$record->Status = $status;
65
+		$record->write();
66
+	}
67 67
 
68
-    /**
69
-     *
70
-     * @return DNData
71
-     */
72
-    protected function DNData()
73
-    {
74
-        return DNData::inst();
75
-    }
68
+	/**
69
+	 *
70
+	 * @return DNData
71
+	 */
72
+	protected function DNData()
73
+	{
74
+		return DNData::inst();
75
+	}
76 76
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,13 +36,13 @@
 block discarded – undo
36 36
         // This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque
37 37
         try {
38 38
             $envCreate = DNCreateEnvironment::get()->byId($this->args['createID']);
39
-            if (!($envCreate && $envCreate->exists())) {
39
+            if(!($envCreate && $envCreate->exists())) {
40 40
                 throw new RuntimeException(sprintf('Could not find create environment record %s', $args['createID']));
41 41
             }
42 42
 
43 43
             // This will throw and exception if it fails.
44 44
             $envCreate->createEnvironment();
45
-        } catch (Exception $e) {
45
+        } catch(Exception $e) {
46 46
             $this->updateStatus('Failed');
47 47
             echo "[-] CreateEnvJob failed" . PHP_EOL;
48 48
             throw $e;
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class CreateEnvJob
3
-{
2
+class CreateEnvJob {
4 3
 
5 4
     /**
6 5
      *
@@ -11,8 +10,7 @@  discard block
 block discarded – undo
11 10
     /**
12 11
      *
13 12
      */
14
-    public function setUp()
15
-    {
13
+    public function setUp() {
16 14
         $this->updateStatus('Started');
17 15
         chdir(BASE_PATH);
18 16
     }
@@ -21,8 +19,7 @@  discard block
 block discarded – undo
21 19
      *
22 20
      * @global array $databaseConfig
23 21
      */
24
-    public function tearDown()
25
-    {
22
+    public function tearDown() {
26 23
         $this->updateStatus('Finished');
27 24
         chdir(BASE_PATH);
28 25
     }
@@ -30,8 +27,7 @@  discard block
 block discarded – undo
30 27
     /**
31 28
      *
32 29
      */
33
-    public function perform()
34
-    {
30
+    public function perform() {
35 31
         echo "[-] CreateEnvJob starting" . PHP_EOL;
36 32
         // This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque
37 33
         try {
@@ -55,8 +51,7 @@  discard block
 block discarded – undo
55 51
      * @param string $status
56 52
      * @global array $databaseConfig
57 53
      */
58
-    protected function updateStatus($status)
59
-    {
54
+    protected function updateStatus($status) {
60 55
         global $databaseConfig;
61 56
         DB::connect($databaseConfig);
62 57
 
@@ -69,8 +64,7 @@  discard block
 block discarded – undo
69 64
      *
70 65
      * @return DNData
71 66
      */
72
-    protected function DNData()
73
-    {
67
+    protected function DNData() {
74 68
         return DNData::inst();
75 69
     }
76 70
 }
Please login to merge, or discard this patch.
code/jobs/DataTransferJob.php 3 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -10,124 +10,124 @@
 block discarded – undo
10 10
 class DataTransferJob
11 11
 {
12 12
 
13
-    /**
14
-     * set by a resque worker
15
-     */
16
-    public $args = array();
17
-
18
-    public function setUp()
19
-    {
20
-        $this->updateStatus('Started');
21
-        chdir(BASE_PATH);
22
-    }
23
-
24
-    public function tearDown()
25
-    {
26
-        $this->updateStatus('Finished');
27
-        chdir(BASE_PATH);
28
-    }
29
-
30
-    public function perform()
31
-    {
32
-        echo "[-] DataTransferJob starting" . PHP_EOL;
33
-        $log = new DeploynautLogFile($this->args['logfile']);
34
-        $dataTransfer = DNDataTransfer::get()->byID($this->args['dataTransferID']);
35
-        $environment = $dataTransfer->Environment();
36
-        $backupDataTransfer = null;
37
-
38
-        if (!empty($this->args['backupBeforePush']) && $dataTransfer->Direction == 'push') {
39
-            $backupDataTransfer = DNDataTransfer::create();
40
-            $backupDataTransfer->EnvironmentID = $environment->ID;
41
-            $backupDataTransfer->Direction = 'get';
42
-            $backupDataTransfer->Mode = $dataTransfer->Mode;
43
-            $backupDataTransfer->DataArchiveID = null;
44
-            $backupDataTransfer->ResqueToken = $dataTransfer->ResqueToken;
45
-            $backupDataTransfer->AuthorID = $dataTransfer->AuthorID;
46
-            $backupDataTransfer->write();
47
-
48
-            $dataTransfer->BackupDataTransferID = $backupDataTransfer->ID;
49
-            $dataTransfer->write();
50
-        }
51
-
52
-        // This is a bit icky, but there is no easy way of capturing a failed run by using the PHP Resque
53
-        try {
54
-            // Disallow concurrent jobs (don't rely on queuing implementation to restrict this)
55
-            // Only consider data transfers started in the last 30 minutes (older jobs probably got stuck)
56
-            $runningTransfers = DNDataTransfer::get()
57
-                ->filter(array(
58
-                    'EnvironmentID' => $environment->ID,
59
-                    'Status' => array('Queued', 'Started'),
60
-                    'Created:GreaterThan' => strtotime('-30 minutes')
61
-                ))
62
-                ->exclude('ID', $dataTransfer->ID);
63
-
64
-            if ($runningTransfers->count()) {
65
-                $runningTransfer = $runningTransfers->first();
66
-                $log->write(sprintf(
67
-                    '[-] Error: another transfer is in progress (started at %s by %s)',
68
-                    $runningTransfer->dbObject('Created')->Nice(),
69
-                    $runningTransfer->Author()->Title
70
-                ));
71
-                throw new RuntimeException(sprintf(
72
-                    'Another transfer is in progress (started at %s by %s)',
73
-                    $runningTransfer->dbObject('Created')->Nice(),
74
-                    $runningTransfer->Author()->Title
75
-                ));
76
-            }
77
-
78
-
79
-            // before we push data to an environment, we'll make a backup first
80
-            if ($backupDataTransfer) {
81
-                $log->write('Backing up existing data');
82
-                $environment->Backend()->dataTransfer(
83
-                    $backupDataTransfer,
84
-                    $log
85
-                );
86
-            }
87
-
88
-            $environment->Backend()->dataTransfer(
89
-                $dataTransfer,
90
-                $log
91
-            );
92
-        } catch (RuntimeException $exc) {
93
-            $log->write($exc->getMessage());
94
-
95
-            if ($backupDataTransfer) {
96
-                $backupDataTransfer->Status = 'Failed';
97
-                $backupDataTransfer->write();
98
-            }
99
-
100
-            $this->updateStatus('Failed');
101
-            echo "[-] DataTransferJob failed" . PHP_EOL;
102
-            throw $exc;
103
-        }
104
-
105
-        if ($backupDataTransfer) {
106
-            $backupDataTransfer->Status = 'Finished';
107
-            $backupDataTransfer->write();
108
-        }
109
-
110
-        echo "[-] DataTransferJob finished" . PHP_EOL;
111
-    }
112
-
113
-    /**
114
-     * @param string $status
115
-     * @global array $databaseConfig
116
-     */
117
-    protected function updateStatus($status)
118
-    {
119
-        global $databaseConfig;
120
-        DB::connect($databaseConfig);
121
-        $env = DNDataTransfer::get()->byID($this->args['dataTransferID']);
122
-        $env->Status = $status;
123
-        $env->write();
124
-    }
125
-
126
-    /**
127
-     * @return DNData
128
-     */
129
-    protected function DNData()
130
-    {
131
-        return DNData::inst();
132
-    }
13
+	/**
14
+	 * set by a resque worker
15
+	 */
16
+	public $args = array();
17
+
18
+	public function setUp()
19
+	{
20
+		$this->updateStatus('Started');
21
+		chdir(BASE_PATH);
22
+	}
23
+
24
+	public function tearDown()
25
+	{
26
+		$this->updateStatus('Finished');
27
+		chdir(BASE_PATH);
28
+	}
29
+
30
+	public function perform()
31
+	{
32
+		echo "[-] DataTransferJob starting" . PHP_EOL;
33
+		$log = new DeploynautLogFile($this->args['logfile']);
34
+		$dataTransfer = DNDataTransfer::get()->byID($this->args['dataTransferID']);
35
+		$environment = $dataTransfer->Environment();
36
+		$backupDataTransfer = null;
37
+
38
+		if (!empty($this->args['backupBeforePush']) && $dataTransfer->Direction == 'push') {
39
+			$backupDataTransfer = DNDataTransfer::create();
40
+			$backupDataTransfer->EnvironmentID = $environment->ID;
41
+			$backupDataTransfer->Direction = 'get';
42
+			$backupDataTransfer->Mode = $dataTransfer->Mode;
43
+			$backupDataTransfer->DataArchiveID = null;
44
+			$backupDataTransfer->ResqueToken = $dataTransfer->ResqueToken;
45
+			$backupDataTransfer->AuthorID = $dataTransfer->AuthorID;
46
+			$backupDataTransfer->write();
47
+
48
+			$dataTransfer->BackupDataTransferID = $backupDataTransfer->ID;
49
+			$dataTransfer->write();
50
+		}
51
+
52
+		// This is a bit icky, but there is no easy way of capturing a failed run by using the PHP Resque
53
+		try {
54
+			// Disallow concurrent jobs (don't rely on queuing implementation to restrict this)
55
+			// Only consider data transfers started in the last 30 minutes (older jobs probably got stuck)
56
+			$runningTransfers = DNDataTransfer::get()
57
+				->filter(array(
58
+					'EnvironmentID' => $environment->ID,
59
+					'Status' => array('Queued', 'Started'),
60
+					'Created:GreaterThan' => strtotime('-30 minutes')
61
+				))
62
+				->exclude('ID', $dataTransfer->ID);
63
+
64
+			if ($runningTransfers->count()) {
65
+				$runningTransfer = $runningTransfers->first();
66
+				$log->write(sprintf(
67
+					'[-] Error: another transfer is in progress (started at %s by %s)',
68
+					$runningTransfer->dbObject('Created')->Nice(),
69
+					$runningTransfer->Author()->Title
70
+				));
71
+				throw new RuntimeException(sprintf(
72
+					'Another transfer is in progress (started at %s by %s)',
73
+					$runningTransfer->dbObject('Created')->Nice(),
74
+					$runningTransfer->Author()->Title
75
+				));
76
+			}
77
+
78
+
79
+			// before we push data to an environment, we'll make a backup first
80
+			if ($backupDataTransfer) {
81
+				$log->write('Backing up existing data');
82
+				$environment->Backend()->dataTransfer(
83
+					$backupDataTransfer,
84
+					$log
85
+				);
86
+			}
87
+
88
+			$environment->Backend()->dataTransfer(
89
+				$dataTransfer,
90
+				$log
91
+			);
92
+		} catch (RuntimeException $exc) {
93
+			$log->write($exc->getMessage());
94
+
95
+			if ($backupDataTransfer) {
96
+				$backupDataTransfer->Status = 'Failed';
97
+				$backupDataTransfer->write();
98
+			}
99
+
100
+			$this->updateStatus('Failed');
101
+			echo "[-] DataTransferJob failed" . PHP_EOL;
102
+			throw $exc;
103
+		}
104
+
105
+		if ($backupDataTransfer) {
106
+			$backupDataTransfer->Status = 'Finished';
107
+			$backupDataTransfer->write();
108
+		}
109
+
110
+		echo "[-] DataTransferJob finished" . PHP_EOL;
111
+	}
112
+
113
+	/**
114
+	 * @param string $status
115
+	 * @global array $databaseConfig
116
+	 */
117
+	protected function updateStatus($status)
118
+	{
119
+		global $databaseConfig;
120
+		DB::connect($databaseConfig);
121
+		$env = DNDataTransfer::get()->byID($this->args['dataTransferID']);
122
+		$env->Status = $status;
123
+		$env->write();
124
+	}
125
+
126
+	/**
127
+	 * @return DNData
128
+	 */
129
+	protected function DNData()
130
+	{
131
+		return DNData::inst();
132
+	}
133 133
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $environment = $dataTransfer->Environment();
36 36
         $backupDataTransfer = null;
37 37
 
38
-        if (!empty($this->args['backupBeforePush']) && $dataTransfer->Direction == 'push') {
38
+        if(!empty($this->args['backupBeforePush']) && $dataTransfer->Direction == 'push') {
39 39
             $backupDataTransfer = DNDataTransfer::create();
40 40
             $backupDataTransfer->EnvironmentID = $environment->ID;
41 41
             $backupDataTransfer->Direction = 'get';
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                 ))
62 62
                 ->exclude('ID', $dataTransfer->ID);
63 63
 
64
-            if ($runningTransfers->count()) {
64
+            if($runningTransfers->count()) {
65 65
                 $runningTransfer = $runningTransfers->first();
66 66
                 $log->write(sprintf(
67 67
                     '[-] Error: another transfer is in progress (started at %s by %s)',
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 
79 79
             // before we push data to an environment, we'll make a backup first
80
-            if ($backupDataTransfer) {
80
+            if($backupDataTransfer) {
81 81
                 $log->write('Backing up existing data');
82 82
                 $environment->Backend()->dataTransfer(
83 83
                     $backupDataTransfer,
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
                 $dataTransfer,
90 90
                 $log
91 91
             );
92
-        } catch (RuntimeException $exc) {
92
+        } catch(RuntimeException $exc) {
93 93
             $log->write($exc->getMessage());
94 94
 
95
-            if ($backupDataTransfer) {
95
+            if($backupDataTransfer) {
96 96
                 $backupDataTransfer->Status = 'Failed';
97 97
                 $backupDataTransfer->write();
98 98
             }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             throw $exc;
103 103
         }
104 104
 
105
-        if ($backupDataTransfer) {
105
+        if($backupDataTransfer) {
106 106
             $backupDataTransfer->Status = 'Finished';
107 107
             $backupDataTransfer->write();
108 108
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -7,28 +7,24 @@  discard block
 block discarded – undo
7 7
  * @package deploynaut
8 8
  * @subpackage jobs
9 9
  */
10
-class DataTransferJob
11
-{
10
+class DataTransferJob {
12 11
 
13 12
     /**
14 13
      * set by a resque worker
15 14
      */
16 15
     public $args = array();
17 16
 
18
-    public function setUp()
19
-    {
17
+    public function setUp() {
20 18
         $this->updateStatus('Started');
21 19
         chdir(BASE_PATH);
22 20
     }
23 21
 
24
-    public function tearDown()
25
-    {
22
+    public function tearDown() {
26 23
         $this->updateStatus('Finished');
27 24
         chdir(BASE_PATH);
28 25
     }
29 26
 
30
-    public function perform()
31
-    {
27
+    public function perform() {
32 28
         echo "[-] DataTransferJob starting" . PHP_EOL;
33 29
         $log = new DeploynautLogFile($this->args['logfile']);
34 30
         $dataTransfer = DNDataTransfer::get()->byID($this->args['dataTransferID']);
@@ -114,8 +110,7 @@  discard block
 block discarded – undo
114 110
      * @param string $status
115 111
      * @global array $databaseConfig
116 112
      */
117
-    protected function updateStatus($status)
118
-    {
113
+    protected function updateStatus($status) {
119 114
         global $databaseConfig;
120 115
         DB::connect($databaseConfig);
121 116
         $env = DNDataTransfer::get()->byID($this->args['dataTransferID']);
@@ -126,8 +121,7 @@  discard block
 block discarded – undo
126 121
     /**
127 122
      * @return DNData
128 123
      */
129
-    protected function DNData()
130
-    {
124
+    protected function DNData() {
131 125
         return DNData::inst();
132 126
     }
133 127
 }
Please login to merge, or discard this patch.
code/jobs/DeployJob.php 3 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -6,89 +6,89 @@
 block discarded – undo
6 6
 class DeployJob
7 7
 {
8 8
 
9
-    /**
10
-     * @var array
11
-     */
12
-    public $args;
9
+	/**
10
+	 * @var array
11
+	 */
12
+	public $args;
13 13
 
14
-    public function setUp()
15
-    {
16
-        $this->updateStatus('Started');
17
-        chdir(BASE_PATH);
18
-    }
14
+	public function setUp()
15
+	{
16
+		$this->updateStatus('Started');
17
+		chdir(BASE_PATH);
18
+	}
19 19
 
20
-    public function tearDown()
21
-    {
22
-        $this->updateStatus('Finished');
23
-        chdir(BASE_PATH);
24
-    }
20
+	public function tearDown()
21
+	{
22
+		$this->updateStatus('Finished');
23
+		chdir(BASE_PATH);
24
+	}
25 25
 
26
-    public function perform()
27
-    {
28
-        echo "[-] DeployJob starting" . PHP_EOL;
29
-        $log = new DeploynautLogFile($this->args['logfile']);
30
-        $DNProject = $this->DNData()->DNProjectList()->filter('Name', $this->args['projectName'])->First();
31
-        $DNEnvironment = $DNProject->Environments()->filter('Name', $this->args['environmentName'])->First();
32
-        // This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque
33
-        try {
34
-            // Disallow concurrent deployments (don't rely on queuing implementation to restrict this)
35
-            // Only consider deployments started in the last 30 minutes (older jobs probably got stuck)
36
-            $runningDeployments = DNDeployment::get()
37
-                ->filter(array(
38
-                    'EnvironmentID' => $DNEnvironment->ID,
39
-                    'Status' => array('Queued', 'Started'),
40
-                    'Created:GreaterThan' => strtotime('-30 minutes')
41
-                ))
42
-                ->exclude('ID', $this->args['deploymentID']);
26
+	public function perform()
27
+	{
28
+		echo "[-] DeployJob starting" . PHP_EOL;
29
+		$log = new DeploynautLogFile($this->args['logfile']);
30
+		$DNProject = $this->DNData()->DNProjectList()->filter('Name', $this->args['projectName'])->First();
31
+		$DNEnvironment = $DNProject->Environments()->filter('Name', $this->args['environmentName'])->First();
32
+		// This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque
33
+		try {
34
+			// Disallow concurrent deployments (don't rely on queuing implementation to restrict this)
35
+			// Only consider deployments started in the last 30 minutes (older jobs probably got stuck)
36
+			$runningDeployments = DNDeployment::get()
37
+				->filter(array(
38
+					'EnvironmentID' => $DNEnvironment->ID,
39
+					'Status' => array('Queued', 'Started'),
40
+					'Created:GreaterThan' => strtotime('-30 minutes')
41
+				))
42
+				->exclude('ID', $this->args['deploymentID']);
43 43
 
44
-            if ($runningDeployments->count()) {
45
-                $runningDeployment = $runningDeployments->first();
46
-                $log->write(sprintf(
47
-                    '[-] Error: another deployment is in progress (started at %s by %s)',
48
-                    $runningDeployment->dbObject('Created')->Nice(),
49
-                    $runningDeployment->Deployer()->Title
50
-                ));
51
-                throw new RuntimeException(sprintf(
52
-                    'Another deployment is in progress (started at %s by %s)',
53
-                    $runningDeployment->dbObject('Created')->Nice(),
54
-                    $runningDeployment->Deployer()->Title
55
-                ));
56
-            }
44
+			if ($runningDeployments->count()) {
45
+				$runningDeployment = $runningDeployments->first();
46
+				$log->write(sprintf(
47
+					'[-] Error: another deployment is in progress (started at %s by %s)',
48
+					$runningDeployment->dbObject('Created')->Nice(),
49
+					$runningDeployment->Deployer()->Title
50
+				));
51
+				throw new RuntimeException(sprintf(
52
+					'Another deployment is in progress (started at %s by %s)',
53
+					$runningDeployment->dbObject('Created')->Nice(),
54
+					$runningDeployment->Deployer()->Title
55
+				));
56
+			}
57 57
 
58
-            $DNEnvironment->Backend()->deploy(
59
-                $DNEnvironment,
60
-                $log,
61
-                $DNProject,
62
-                // Pass all args to give the backend full visibility. These args also contain
63
-                // all options from the DeploymentStrategy merged in, including sha.
64
-                $this->args
65
-            );
66
-        } catch (Exception $e) {
67
-            $this->updateStatus('Failed');
68
-            echo "[-] DeployJob failed" . PHP_EOL;
69
-            throw $e;
70
-        }
71
-        echo "[-] DeployJob finished" . PHP_EOL;
72
-    }
58
+			$DNEnvironment->Backend()->deploy(
59
+				$DNEnvironment,
60
+				$log,
61
+				$DNProject,
62
+				// Pass all args to give the backend full visibility. These args also contain
63
+				// all options from the DeploymentStrategy merged in, including sha.
64
+				$this->args
65
+			);
66
+		} catch (Exception $e) {
67
+			$this->updateStatus('Failed');
68
+			echo "[-] DeployJob failed" . PHP_EOL;
69
+			throw $e;
70
+		}
71
+		echo "[-] DeployJob finished" . PHP_EOL;
72
+	}
73 73
 
74
-    /**
75
-     * @param string $status
76
-     * @global array $databaseConfig
77
-     */
78
-    protected function updateStatus($status)
79
-    {
80
-        global $databaseConfig;
81
-        DB::connect($databaseConfig);
82
-        $dnDeployment = DNDeployment::get()->byID($this->args['deploymentID']);
83
-        $dnDeployment->Status = $status;
84
-        $dnDeployment->write();
85
-    }
74
+	/**
75
+	 * @param string $status
76
+	 * @global array $databaseConfig
77
+	 */
78
+	protected function updateStatus($status)
79
+	{
80
+		global $databaseConfig;
81
+		DB::connect($databaseConfig);
82
+		$dnDeployment = DNDeployment::get()->byID($this->args['deploymentID']);
83
+		$dnDeployment->Status = $status;
84
+		$dnDeployment->write();
85
+	}
86 86
 
87
-    /**
88
-     * @return DNData
89
-     */
90
-    protected function DNData()
91
-    {
92
-        return DNData::inst();
93
-    }
87
+	/**
88
+	 * @return DNData
89
+	 */
90
+	protected function DNData()
91
+	{
92
+		return DNData::inst();
93
+	}
94 94
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
                 ))
42 42
                 ->exclude('ID', $this->args['deploymentID']);
43 43
 
44
-            if ($runningDeployments->count()) {
44
+            if($runningDeployments->count()) {
45 45
                 $runningDeployment = $runningDeployments->first();
46 46
                 $log->write(sprintf(
47 47
                     '[-] Error: another deployment is in progress (started at %s by %s)',
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                 // all options from the DeploymentStrategy merged in, including sha.
64 64
                 $this->args
65 65
             );
66
-        } catch (Exception $e) {
66
+        } catch(Exception $e) {
67 67
             $this->updateStatus('Failed');
68 68
             echo "[-] DeployJob failed" . PHP_EOL;
69 69
             throw $e;
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,28 +3,24 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  * Runs a deployment via the most appropriate backend
5 5
  */
6
-class DeployJob
7
-{
6
+class DeployJob {
8 7
 
9 8
     /**
10 9
      * @var array
11 10
      */
12 11
     public $args;
13 12
 
14
-    public function setUp()
15
-    {
13
+    public function setUp() {
16 14
         $this->updateStatus('Started');
17 15
         chdir(BASE_PATH);
18 16
     }
19 17
 
20
-    public function tearDown()
21
-    {
18
+    public function tearDown() {
22 19
         $this->updateStatus('Finished');
23 20
         chdir(BASE_PATH);
24 21
     }
25 22
 
26
-    public function perform()
27
-    {
23
+    public function perform() {
28 24
         echo "[-] DeployJob starting" . PHP_EOL;
29 25
         $log = new DeploynautLogFile($this->args['logfile']);
30 26
         $DNProject = $this->DNData()->DNProjectList()->filter('Name', $this->args['projectName'])->First();
@@ -75,8 +71,7 @@  discard block
 block discarded – undo
75 71
      * @param string $status
76 72
      * @global array $databaseConfig
77 73
      */
78
-    protected function updateStatus($status)
79
-    {
74
+    protected function updateStatus($status) {
80 75
         global $databaseConfig;
81 76
         DB::connect($databaseConfig);
82 77
         $dnDeployment = DNDeployment::get()->byID($this->args['deploymentID']);
@@ -87,8 +82,7 @@  discard block
 block discarded – undo
87 82
     /**
88 83
      * @return DNData
89 84
      */
90
-    protected function DNData()
91
-    {
85
+    protected function DNData() {
92 86
         return DNData::inst();
93 87
     }
94 88
 }
Please login to merge, or discard this patch.
code/jobs/FetchJob.php 3 patches
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -3,161 +3,161 @@
 block discarded – undo
3 3
 class FetchJob
4 4
 {
5 5
 
6
-    public $args;
7
-
8
-    /**
9
-     * @var DNProject
10
-     */
11
-    protected $project;
12
-
13
-    /**
14
-     * @var DeploynautLogFile
15
-     */
16
-    protected $log;
17
-
18
-    /**
19
-     * @var string
20
-     */
21
-    protected $user;
22
-
23
-    /**
24
-     * @global array $databaseConfig
25
-     */
26
-    public function setUp()
27
-    {
28
-        global $databaseConfig;
29
-        DB::connect($databaseConfig);
30
-
31
-        $this->updateStatus('Started');
32
-        chdir(BASE_PATH);
33
-    }
34
-
35
-    public function tearDown()
36
-    {
37
-        $this->updateStatus('Finished');
38
-        chdir(BASE_PATH);
39
-    }
40
-
41
-    public function perform()
42
-    {
43
-        set_time_limit(0);
44
-
45
-        if (!empty($this->args['logfile'])) {
46
-            $this->log = new DeploynautLogFile($this->args['logfile']);
47
-        }
48
-
49
-        $this->project = DNProject::get()->byId($this->args['projectID']);
50
-        if (!($this->project && $this->project->exists())) {
51
-            throw new RuntimeException(sprintf('Project ID %s not found', $this->args['projectID']));
52
-        }
53
-
54
-        $this->user = DNData::inst()->getGitUser() ?: null;
55
-
56
-        // Disallow concurrent git fetches on the same project.
57
-        // Only consider fetches started in the last 30 minutes (older jobs probably got stuck)
58
-        if (!empty($this->args['fetchID'])) {
59
-            $runningFetches = DNGitFetch::get()
60
-                ->filter(array(
61
-                    'ProjectID' => $this->project->ID,
62
-                    'Status' => array('Queued', 'Started'),
63
-                    'Created:GreaterThan' => strtotime('-30 minutes')
64
-                ))
65
-                ->exclude('ID', $this->args['fetchID']);
66
-
67
-            if ($runningFetches->count()) {
68
-                $runningFetch = $runningFetches->first();
69
-                $message = sprintf(
70
-                    'Another fetch is in progress (started at %s by %s)',
71
-                    $runningFetch->dbObject('Created')->Nice(),
72
-                    $runningFetch->Deployer()->Title
73
-                );
74
-                if ($this->log) {
75
-                    $this->log->write($message);
76
-                }
77
-                throw new RuntimeException($message);
78
-            }
79
-        }
80
-
81
-        // Decide whether we need to just update what we already have
82
-        // or initiate a clone if no local repo exists.
83
-        try {
84
-            if ($this->project->repoExists() && empty($this->args['forceClone'])) {
85
-                $this->fetchRepo();
86
-            } else {
87
-                $this->cloneRepo();
88
-            }
89
-        } catch (Exception $e) {
90
-            $this->updateStatus('Failed');
91
-            if ($this->log) {
92
-                $this->log->write($e->getMessage());
93
-            }
94
-            throw $e;
95
-        }
96
-    }
97
-
98
-    protected function fetchRepo()
99
-    {
100
-        $this->runCommand(
101
-            'git fetch -p origin +refs/heads/*:refs/heads/* --tags',
102
-            $this->project->getLocalCVSPath()
103
-        );
104
-    }
105
-
106
-    protected function cloneRepo()
107
-    {
108
-        if (file_exists($this->project->getLocalCVSPath())) {
109
-            $this->runCommand(sprintf(
110
-                'rm -rf %s',
111
-                escapeshellarg($this->project->getLocalCVSPath())
112
-            ));
113
-        }
114
-
115
-        $this->runCommand(sprintf(
116
-            'git clone --bare -q %s %s',
117
-            escapeshellarg($this->project->CVSPath),
118
-            escapeshellarg($this->project->getLocalCVSPath())
119
-        ));
120
-    }
121
-
122
-    /**
123
-     * Run a shell command.
124
-     *
125
-     * @param string $command The command to run
126
-     * @param string|null $workingDir The working dir to run command in
127
-     * @throws RuntimeException
128
-     */
129
-    protected function runCommand($command, $workingDir = null)
130
-    {
131
-        if (!empty($this->user)) {
132
-            $command = sprintf('sudo -u %s %s', $this->user, $command);
133
-        }
134
-        if ($this->log) {
135
-            $this->log->write(sprintf('Running command: %s', $command));
136
-        }
137
-        $process = new \Symfony\Component\Process\Process($command, $workingDir);
138
-        $process->setEnv($this->project->getProcessEnv());
139
-        $process->setTimeout(1800);
140
-        $process->run();
141
-        if (!$process->isSuccessful()) {
142
-            throw new RuntimeException($process->getErrorOutput());
143
-        }
144
-    }
145
-
146
-    /**
147
-     * @param string $status
148
-     * @global array $databaseConfig
149
-     */
150
-    protected function updateStatus($status)
151
-    {
152
-        global $databaseConfig;
153
-        DB::connect($databaseConfig);
154
-
155
-        if (!empty($this->args['fetchID'])) {
156
-            $fetch = DNGitFetch::get()->byID($this->args['fetchID']);
157
-            if ($fetch && $fetch->exists()) {
158
-                $fetch->Status = $status;
159
-                $fetch->write();
160
-            }
161
-        }
162
-    }
6
+	public $args;
7
+
8
+	/**
9
+	 * @var DNProject
10
+	 */
11
+	protected $project;
12
+
13
+	/**
14
+	 * @var DeploynautLogFile
15
+	 */
16
+	protected $log;
17
+
18
+	/**
19
+	 * @var string
20
+	 */
21
+	protected $user;
22
+
23
+	/**
24
+	 * @global array $databaseConfig
25
+	 */
26
+	public function setUp()
27
+	{
28
+		global $databaseConfig;
29
+		DB::connect($databaseConfig);
30
+
31
+		$this->updateStatus('Started');
32
+		chdir(BASE_PATH);
33
+	}
34
+
35
+	public function tearDown()
36
+	{
37
+		$this->updateStatus('Finished');
38
+		chdir(BASE_PATH);
39
+	}
40
+
41
+	public function perform()
42
+	{
43
+		set_time_limit(0);
44
+
45
+		if (!empty($this->args['logfile'])) {
46
+			$this->log = new DeploynautLogFile($this->args['logfile']);
47
+		}
48
+
49
+		$this->project = DNProject::get()->byId($this->args['projectID']);
50
+		if (!($this->project && $this->project->exists())) {
51
+			throw new RuntimeException(sprintf('Project ID %s not found', $this->args['projectID']));
52
+		}
53
+
54
+		$this->user = DNData::inst()->getGitUser() ?: null;
55
+
56
+		// Disallow concurrent git fetches on the same project.
57
+		// Only consider fetches started in the last 30 minutes (older jobs probably got stuck)
58
+		if (!empty($this->args['fetchID'])) {
59
+			$runningFetches = DNGitFetch::get()
60
+				->filter(array(
61
+					'ProjectID' => $this->project->ID,
62
+					'Status' => array('Queued', 'Started'),
63
+					'Created:GreaterThan' => strtotime('-30 minutes')
64
+				))
65
+				->exclude('ID', $this->args['fetchID']);
66
+
67
+			if ($runningFetches->count()) {
68
+				$runningFetch = $runningFetches->first();
69
+				$message = sprintf(
70
+					'Another fetch is in progress (started at %s by %s)',
71
+					$runningFetch->dbObject('Created')->Nice(),
72
+					$runningFetch->Deployer()->Title
73
+				);
74
+				if ($this->log) {
75
+					$this->log->write($message);
76
+				}
77
+				throw new RuntimeException($message);
78
+			}
79
+		}
80
+
81
+		// Decide whether we need to just update what we already have
82
+		// or initiate a clone if no local repo exists.
83
+		try {
84
+			if ($this->project->repoExists() && empty($this->args['forceClone'])) {
85
+				$this->fetchRepo();
86
+			} else {
87
+				$this->cloneRepo();
88
+			}
89
+		} catch (Exception $e) {
90
+			$this->updateStatus('Failed');
91
+			if ($this->log) {
92
+				$this->log->write($e->getMessage());
93
+			}
94
+			throw $e;
95
+		}
96
+	}
97
+
98
+	protected function fetchRepo()
99
+	{
100
+		$this->runCommand(
101
+			'git fetch -p origin +refs/heads/*:refs/heads/* --tags',
102
+			$this->project->getLocalCVSPath()
103
+		);
104
+	}
105
+
106
+	protected function cloneRepo()
107
+	{
108
+		if (file_exists($this->project->getLocalCVSPath())) {
109
+			$this->runCommand(sprintf(
110
+				'rm -rf %s',
111
+				escapeshellarg($this->project->getLocalCVSPath())
112
+			));
113
+		}
114
+
115
+		$this->runCommand(sprintf(
116
+			'git clone --bare -q %s %s',
117
+			escapeshellarg($this->project->CVSPath),
118
+			escapeshellarg($this->project->getLocalCVSPath())
119
+		));
120
+	}
121
+
122
+	/**
123
+	 * Run a shell command.
124
+	 *
125
+	 * @param string $command The command to run
126
+	 * @param string|null $workingDir The working dir to run command in
127
+	 * @throws RuntimeException
128
+	 */
129
+	protected function runCommand($command, $workingDir = null)
130
+	{
131
+		if (!empty($this->user)) {
132
+			$command = sprintf('sudo -u %s %s', $this->user, $command);
133
+		}
134
+		if ($this->log) {
135
+			$this->log->write(sprintf('Running command: %s', $command));
136
+		}
137
+		$process = new \Symfony\Component\Process\Process($command, $workingDir);
138
+		$process->setEnv($this->project->getProcessEnv());
139
+		$process->setTimeout(1800);
140
+		$process->run();
141
+		if (!$process->isSuccessful()) {
142
+			throw new RuntimeException($process->getErrorOutput());
143
+		}
144
+	}
145
+
146
+	/**
147
+	 * @param string $status
148
+	 * @global array $databaseConfig
149
+	 */
150
+	protected function updateStatus($status)
151
+	{
152
+		global $databaseConfig;
153
+		DB::connect($databaseConfig);
154
+
155
+		if (!empty($this->args['fetchID'])) {
156
+			$fetch = DNGitFetch::get()->byID($this->args['fetchID']);
157
+			if ($fetch && $fetch->exists()) {
158
+				$fetch->Status = $status;
159
+				$fetch->write();
160
+			}
161
+		}
162
+	}
163 163
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
     {
43 43
         set_time_limit(0);
44 44
 
45
-        if (!empty($this->args['logfile'])) {
45
+        if(!empty($this->args['logfile'])) {
46 46
             $this->log = new DeploynautLogFile($this->args['logfile']);
47 47
         }
48 48
 
49 49
         $this->project = DNProject::get()->byId($this->args['projectID']);
50
-        if (!($this->project && $this->project->exists())) {
50
+        if(!($this->project && $this->project->exists())) {
51 51
             throw new RuntimeException(sprintf('Project ID %s not found', $this->args['projectID']));
52 52
         }
53 53
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
         // Disallow concurrent git fetches on the same project.
57 57
         // Only consider fetches started in the last 30 minutes (older jobs probably got stuck)
58
-        if (!empty($this->args['fetchID'])) {
58
+        if(!empty($this->args['fetchID'])) {
59 59
             $runningFetches = DNGitFetch::get()
60 60
                 ->filter(array(
61 61
                     'ProjectID' => $this->project->ID,
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
                 ))
65 65
                 ->exclude('ID', $this->args['fetchID']);
66 66
 
67
-            if ($runningFetches->count()) {
67
+            if($runningFetches->count()) {
68 68
                 $runningFetch = $runningFetches->first();
69 69
                 $message = sprintf(
70 70
                     'Another fetch is in progress (started at %s by %s)',
71 71
                     $runningFetch->dbObject('Created')->Nice(),
72 72
                     $runningFetch->Deployer()->Title
73 73
                 );
74
-                if ($this->log) {
74
+                if($this->log) {
75 75
                     $this->log->write($message);
76 76
                 }
77 77
                 throw new RuntimeException($message);
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
         // Decide whether we need to just update what we already have
82 82
         // or initiate a clone if no local repo exists.
83 83
         try {
84
-            if ($this->project->repoExists() && empty($this->args['forceClone'])) {
84
+            if($this->project->repoExists() && empty($this->args['forceClone'])) {
85 85
                 $this->fetchRepo();
86 86
             } else {
87 87
                 $this->cloneRepo();
88 88
             }
89
-        } catch (Exception $e) {
89
+        } catch(Exception $e) {
90 90
             $this->updateStatus('Failed');
91
-            if ($this->log) {
91
+            if($this->log) {
92 92
                 $this->log->write($e->getMessage());
93 93
             }
94 94
             throw $e;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
     protected function cloneRepo()
107 107
     {
108
-        if (file_exists($this->project->getLocalCVSPath())) {
108
+        if(file_exists($this->project->getLocalCVSPath())) {
109 109
             $this->runCommand(sprintf(
110 110
                 'rm -rf %s',
111 111
                 escapeshellarg($this->project->getLocalCVSPath())
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
      */
129 129
     protected function runCommand($command, $workingDir = null)
130 130
     {
131
-        if (!empty($this->user)) {
131
+        if(!empty($this->user)) {
132 132
             $command = sprintf('sudo -u %s %s', $this->user, $command);
133 133
         }
134
-        if ($this->log) {
134
+        if($this->log) {
135 135
             $this->log->write(sprintf('Running command: %s', $command));
136 136
         }
137 137
         $process = new \Symfony\Component\Process\Process($command, $workingDir);
138 138
         $process->setEnv($this->project->getProcessEnv());
139 139
         $process->setTimeout(1800);
140 140
         $process->run();
141
-        if (!$process->isSuccessful()) {
141
+        if(!$process->isSuccessful()) {
142 142
             throw new RuntimeException($process->getErrorOutput());
143 143
         }
144 144
     }
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
         global $databaseConfig;
153 153
         DB::connect($databaseConfig);
154 154
 
155
-        if (!empty($this->args['fetchID'])) {
155
+        if(!empty($this->args['fetchID'])) {
156 156
             $fetch = DNGitFetch::get()->byID($this->args['fetchID']);
157
-            if ($fetch && $fetch->exists()) {
157
+            if($fetch && $fetch->exists()) {
158 158
                 $fetch->Status = $status;
159 159
                 $fetch->write();
160 160
             }
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class FetchJob
4
-{
3
+class FetchJob {
5 4
 
6 5
     public $args;
7 6
 
@@ -23,8 +22,7 @@  discard block
 block discarded – undo
23 22
     /**
24 23
      * @global array $databaseConfig
25 24
      */
26
-    public function setUp()
27
-    {
25
+    public function setUp() {
28 26
         global $databaseConfig;
29 27
         DB::connect($databaseConfig);
30 28
 
@@ -32,14 +30,12 @@  discard block
 block discarded – undo
32 30
         chdir(BASE_PATH);
33 31
     }
34 32
 
35
-    public function tearDown()
36
-    {
33
+    public function tearDown() {
37 34
         $this->updateStatus('Finished');
38 35
         chdir(BASE_PATH);
39 36
     }
40 37
 
41
-    public function perform()
42
-    {
38
+    public function perform() {
43 39
         set_time_limit(0);
44 40
 
45 41
         if (!empty($this->args['logfile'])) {
@@ -95,16 +91,14 @@  discard block
 block discarded – undo
95 91
         }
96 92
     }
97 93
 
98
-    protected function fetchRepo()
99
-    {
94
+    protected function fetchRepo() {
100 95
         $this->runCommand(
101 96
             'git fetch -p origin +refs/heads/*:refs/heads/* --tags',
102 97
             $this->project->getLocalCVSPath()
103 98
         );
104 99
     }
105 100
 
106
-    protected function cloneRepo()
107
-    {
101
+    protected function cloneRepo() {
108 102
         if (file_exists($this->project->getLocalCVSPath())) {
109 103
             $this->runCommand(sprintf(
110 104
                 'rm -rf %s',
@@ -126,8 +120,7 @@  discard block
 block discarded – undo
126 120
      * @param string|null $workingDir The working dir to run command in
127 121
      * @throws RuntimeException
128 122
      */
129
-    protected function runCommand($command, $workingDir = null)
130
-    {
123
+    protected function runCommand($command, $workingDir = null) {
131 124
         if (!empty($this->user)) {
132 125
             $command = sprintf('sudo -u %s %s', $this->user, $command);
133 126
         }
@@ -147,8 +140,7 @@  discard block
 block discarded – undo
147 140
      * @param string $status
148 141
      * @global array $databaseConfig
149 142
      */
150
-    protected function updateStatus($status)
151
-    {
143
+    protected function updateStatus($status) {
152 144
         global $databaseConfig;
153 145
         DB::connect($databaseConfig);
154 146
 
Please login to merge, or discard this patch.
code/jobs/PingJob.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -7,38 +7,38 @@
 block discarded – undo
7 7
 class PingJob
8 8
 {
9 9
 
10
-    /**
11
-     * @var array
12
-     */
13
-    public $args;
10
+	/**
11
+	 * @var array
12
+	 */
13
+	public $args;
14 14
 
15
-    /**
16
-     * @global array $databaseConfig
17
-     */
18
-    public function setUp()
19
-    {
20
-        global $databaseConfig;
21
-        DB::connect($databaseConfig);
22
-        chdir(BASE_PATH);
23
-    }
15
+	/**
16
+	 * @global array $databaseConfig
17
+	 */
18
+	public function setUp()
19
+	{
20
+		global $databaseConfig;
21
+		DB::connect($databaseConfig);
22
+		chdir(BASE_PATH);
23
+	}
24 24
 
25
-    /**
26
-     * @return DNData
27
-     */
28
-    public function DNData()
29
-    {
30
-        return DNData::inst();
31
-    }
25
+	/**
26
+	 * @return DNData
27
+	 */
28
+	public function DNData()
29
+	{
30
+		return DNData::inst();
31
+	}
32 32
 
33
-    /**
34
-     * Do the actual job by calling the appropiate backend
35
-     */
36
-    public function perform()
37
-    {
38
-        echo "[-] PingJob starting" . PHP_EOL;
39
-        $log = new DeploynautLogFile($this->args['logfile']);
40
-        $DNProject = $this->DNData()->DNProjectList()->filter('Name', $this->args['projectName'])->First();
41
-        $DNEnvironment = $DNProject->Environments()->filter('Name', $this->args['environmentName'])->First();
42
-        $DNEnvironment->Backend()->ping($DNEnvironment, $log, $DNProject);
43
-    }
33
+	/**
34
+	 * Do the actual job by calling the appropiate backend
35
+	 */
36
+	public function perform()
37
+	{
38
+		echo "[-] PingJob starting" . PHP_EOL;
39
+		$log = new DeploynautLogFile($this->args['logfile']);
40
+		$DNProject = $this->DNData()->DNProjectList()->filter('Name', $this->args['projectName'])->First();
41
+		$DNEnvironment = $DNProject->Environments()->filter('Name', $this->args['environmentName'])->First();
42
+		$DNEnvironment->Backend()->ping($DNEnvironment, $log, $DNProject);
43
+	}
44 44
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@  discard block
 block discarded – undo
4 4
  * Runs a capistrano job that will check the connection and that all folders with
5 5
  * permission are setup correctly
6 6
  */
7
-class PingJob
8
-{
7
+class PingJob {
9 8
 
10 9
     /**
11 10
      * @var array
@@ -15,8 +14,7 @@  discard block
 block discarded – undo
15 14
     /**
16 15
      * @global array $databaseConfig
17 16
      */
18
-    public function setUp()
19
-    {
17
+    public function setUp() {
20 18
         global $databaseConfig;
21 19
         DB::connect($databaseConfig);
22 20
         chdir(BASE_PATH);
@@ -25,16 +23,14 @@  discard block
 block discarded – undo
25 23
     /**
26 24
      * @return DNData
27 25
      */
28
-    public function DNData()
29
-    {
26
+    public function DNData() {
30 27
         return DNData::inst();
31 28
     }
32 29
 
33 30
     /**
34 31
      * Do the actual job by calling the appropiate backend
35 32
      */
36
-    public function perform()
37
-    {
33
+    public function perform() {
38 34
         echo "[-] PingJob starting" . PHP_EOL;
39 35
         $log = new DeploynautLogFile($this->args['logfile']);
40 36
         $DNProject = $this->DNData()->DNProjectList()->filter('Name', $this->args['projectName'])->First();
Please login to merge, or discard this patch.
code/model/DNBranch.php 3 patches
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -8,113 +8,113 @@
 block discarded – undo
8 8
 class DNBranch extends ViewableData
9 9
 {
10 10
 
11
-    /**
12
-     * @var Gitonomy\Git\Reference\Branch
13
-     */
14
-    protected $branch = null;
15
-
16
-    /**
17
-     * @var DNProject
18
-     */
19
-    protected $project = null;
20
-
21
-    /**
22
-     * @var DNData
23
-     */
24
-    protected $data = null;
25
-
26
-    private static $casting = array(
27
-        'Name' => 'Text',
28
-        'SHA' => 'Text'
29
-    );
30
-
31
-    /**
32
-     * @var SS_Datetime
33
-     */
34
-    protected $_lastUpdatedCache = '';
35
-
36
-    /**
37
-     * @param DNProject $project
38
-     * @param DNData $data
39
-     */
40
-    public function __construct(Gitonomy\Git\Reference\Branch $branch, DNProject $project, DNData $data)
41
-    {
42
-        $this->branch = $branch;
43
-        $this->project = $project;
44
-        $this->data = $data;
45
-    }
46
-
47
-    public function __toString()
48
-    {
49
-        return $this->Name();
50
-    }
51
-
52
-    /**
53
-     * @return string
54
-     */
55
-    public function Name()
56
-    {
57
-        return (string)htmlentities($this->branch->getName());
58
-    }
59
-
60
-    public function Link()
61
-    {
62
-        // Use a get-var for branch so that it can handle unsafe chars better
63
-        return Controller::join_links($this->project->Link(), 'branch?name=' . urlencode($this->Name()));
64
-    }
65
-
66
-    /**
67
-     * @return string
68
-     */
69
-    public function SHA()
70
-    {
71
-        return (string)htmlentities($this->branch->getCommit()->getHash());
72
-    }
73
-
74
-    /**
75
-     * Provides a DNBuildList of builds found in this project.
76
-     */
77
-    public function DNBuildList()
78
-    {
79
-        $blockBranch = $this->branch->getName() == 'master' ? null : 'master';
80
-        return DNReferenceList::create($this->project, $this->data, $this->branch, $blockBranch);
81
-    }
82
-
83
-    /**
84
-     * @return SS_Datetime
85
-     */
86
-    public function LastUpdated()
87
-    {
88
-        if ($this->_lastUpdatedCache) {
89
-            return $this->_lastUpdatedCache;
90
-        }
91
-        try {
92
-            $created = $this->branch->getCommit()->getCommitterDate();
93
-        } catch (Exception $e) {
94
-            //occasionally parsing will fail this is a fallback to make it still work
95
-            return new SS_Datetime();
96
-        }
97
-        // gitonomy sets the time to UTC, so now we set the timezone to
98
-        // whatever PHP is set to (date.timezone). This will change in the future if each
99
-        // deploynaut user has their own timezone
100
-
101
-        $created->setTimezone(new DateTimeZone(date_default_timezone_get()));
102
-
103
-        $date = new SS_Datetime();
104
-        $date->setValue($created->format('Y-m-d H:i:s'));
105
-        $this->_lastUpdatedCache = $date;
106
-        return $date;
107
-    }
108
-
109
-    /**
110
-     * @return string
111
-     */
112
-    public function IsOpenByDefault()
113
-    {
114
-        if ($this->Name() == 'master') {
115
-            return " open";
116
-        } else {
117
-            return "";
118
-        }
119
-    }
11
+	/**
12
+	 * @var Gitonomy\Git\Reference\Branch
13
+	 */
14
+	protected $branch = null;
15
+
16
+	/**
17
+	 * @var DNProject
18
+	 */
19
+	protected $project = null;
20
+
21
+	/**
22
+	 * @var DNData
23
+	 */
24
+	protected $data = null;
25
+
26
+	private static $casting = array(
27
+		'Name' => 'Text',
28
+		'SHA' => 'Text'
29
+	);
30
+
31
+	/**
32
+	 * @var SS_Datetime
33
+	 */
34
+	protected $_lastUpdatedCache = '';
35
+
36
+	/**
37
+	 * @param DNProject $project
38
+	 * @param DNData $data
39
+	 */
40
+	public function __construct(Gitonomy\Git\Reference\Branch $branch, DNProject $project, DNData $data)
41
+	{
42
+		$this->branch = $branch;
43
+		$this->project = $project;
44
+		$this->data = $data;
45
+	}
46
+
47
+	public function __toString()
48
+	{
49
+		return $this->Name();
50
+	}
51
+
52
+	/**
53
+	 * @return string
54
+	 */
55
+	public function Name()
56
+	{
57
+		return (string)htmlentities($this->branch->getName());
58
+	}
59
+
60
+	public function Link()
61
+	{
62
+		// Use a get-var for branch so that it can handle unsafe chars better
63
+		return Controller::join_links($this->project->Link(), 'branch?name=' . urlencode($this->Name()));
64
+	}
65
+
66
+	/**
67
+	 * @return string
68
+	 */
69
+	public function SHA()
70
+	{
71
+		return (string)htmlentities($this->branch->getCommit()->getHash());
72
+	}
73
+
74
+	/**
75
+	 * Provides a DNBuildList of builds found in this project.
76
+	 */
77
+	public function DNBuildList()
78
+	{
79
+		$blockBranch = $this->branch->getName() == 'master' ? null : 'master';
80
+		return DNReferenceList::create($this->project, $this->data, $this->branch, $blockBranch);
81
+	}
82
+
83
+	/**
84
+	 * @return SS_Datetime
85
+	 */
86
+	public function LastUpdated()
87
+	{
88
+		if ($this->_lastUpdatedCache) {
89
+			return $this->_lastUpdatedCache;
90
+		}
91
+		try {
92
+			$created = $this->branch->getCommit()->getCommitterDate();
93
+		} catch (Exception $e) {
94
+			//occasionally parsing will fail this is a fallback to make it still work
95
+			return new SS_Datetime();
96
+		}
97
+		// gitonomy sets the time to UTC, so now we set the timezone to
98
+		// whatever PHP is set to (date.timezone). This will change in the future if each
99
+		// deploynaut user has their own timezone
100
+
101
+		$created->setTimezone(new DateTimeZone(date_default_timezone_get()));
102
+
103
+		$date = new SS_Datetime();
104
+		$date->setValue($created->format('Y-m-d H:i:s'));
105
+		$this->_lastUpdatedCache = $date;
106
+		return $date;
107
+	}
108
+
109
+	/**
110
+	 * @return string
111
+	 */
112
+	public function IsOpenByDefault()
113
+	{
114
+		if ($this->Name() == 'master') {
115
+			return " open";
116
+		} else {
117
+			return "";
118
+		}
119
+	}
120 120
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function LastUpdated()
87 87
     {
88
-        if ($this->_lastUpdatedCache) {
88
+        if($this->_lastUpdatedCache) {
89 89
             return $this->_lastUpdatedCache;
90 90
         }
91 91
         try {
92 92
             $created = $this->branch->getCommit()->getCommitterDate();
93
-        } catch (Exception $e) {
93
+        } catch(Exception $e) {
94 94
             //occasionally parsing will fail this is a fallback to make it still work
95 95
             return new SS_Datetime();
96 96
         }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function IsOpenByDefault()
113 113
     {
114
-        if ($this->Name() == 'master') {
114
+        if($this->Name() == 'master') {
115 115
             return " open";
116 116
         } else {
117 117
             return "";
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  * @method string getName()
7 7
  */
8
-class DNBranch extends ViewableData
9
-{
8
+class DNBranch extends ViewableData {
10 9
 
11 10
     /**
12 11
      * @var Gitonomy\Git\Reference\Branch
@@ -37,28 +36,24 @@  discard block
 block discarded – undo
37 36
      * @param DNProject $project
38 37
      * @param DNData $data
39 38
      */
40
-    public function __construct(Gitonomy\Git\Reference\Branch $branch, DNProject $project, DNData $data)
41
-    {
39
+    public function __construct(Gitonomy\Git\Reference\Branch $branch, DNProject $project, DNData $data) {
42 40
         $this->branch = $branch;
43 41
         $this->project = $project;
44 42
         $this->data = $data;
45 43
     }
46 44
 
47
-    public function __toString()
48
-    {
45
+    public function __toString() {
49 46
         return $this->Name();
50 47
     }
51 48
 
52 49
     /**
53 50
      * @return string
54 51
      */
55
-    public function Name()
56
-    {
52
+    public function Name() {
57 53
         return (string)htmlentities($this->branch->getName());
58 54
     }
59 55
 
60
-    public function Link()
61
-    {
56
+    public function Link() {
62 57
         // Use a get-var for branch so that it can handle unsafe chars better
63 58
         return Controller::join_links($this->project->Link(), 'branch?name=' . urlencode($this->Name()));
64 59
     }
@@ -66,16 +61,14 @@  discard block
 block discarded – undo
66 61
     /**
67 62
      * @return string
68 63
      */
69
-    public function SHA()
70
-    {
64
+    public function SHA() {
71 65
         return (string)htmlentities($this->branch->getCommit()->getHash());
72 66
     }
73 67
 
74 68
     /**
75 69
      * Provides a DNBuildList of builds found in this project.
76 70
      */
77
-    public function DNBuildList()
78
-    {
71
+    public function DNBuildList() {
79 72
         $blockBranch = $this->branch->getName() == 'master' ? null : 'master';
80 73
         return DNReferenceList::create($this->project, $this->data, $this->branch, $blockBranch);
81 74
     }
@@ -83,8 +76,7 @@  discard block
 block discarded – undo
83 76
     /**
84 77
      * @return SS_Datetime
85 78
      */
86
-    public function LastUpdated()
87
-    {
79
+    public function LastUpdated() {
88 80
         if ($this->_lastUpdatedCache) {
89 81
             return $this->_lastUpdatedCache;
90 82
         }
@@ -109,8 +101,7 @@  discard block
 block discarded – undo
109 101
     /**
110 102
      * @return string
111 103
      */
112
-    public function IsOpenByDefault()
113
-    {
104
+    public function IsOpenByDefault() {
114 105
         if ($this->Name() == 'master') {
115 106
             return " open";
116 107
         } else {
Please login to merge, or discard this patch.
code/model/DNBranchList.php 3 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -6,120 +6,120 @@
 block discarded – undo
6 6
 class DNBranchList extends ArrayList
7 7
 {
8 8
 
9
-    /**
10
-     * @var string
11
-     */
12
-    protected static $refs_dir = '';
13
-
14
-    /**
15
-     * @var bool
16
-     */
17
-    protected $loaded = false;
18
-
19
-    /**
20
-     * @var array
21
-     */
22
-    protected $builds = array();
23
-
24
-    /**
25
-     * @var DNProject
26
-     */
27
-    protected $project;
28
-
29
-    /**
30
-     * @var DNData
31
-     */
32
-    protected $data;
33
-
34
-    public static function set_refs_dir($refsDir)
35
-    {
36
-        self::$refs_dir = $refsDir;
37
-    }
38
-
39
-    public static function get_refs_dir()
40
-    {
41
-        return self::$refs_dir;
42
-    }
43
-
44
-    /**
45
-     * @param DNProject $project
46
-     * @param DNData $data
47
-     */
48
-    public function __construct(DNProject $project, DNData $data)
49
-    {
50
-        $this->project = $project;
51
-        $this->data = $data;
52
-        parent::__construct(array());
53
-    }
54
-
55
-    /**
56
-     * @return array
57
-     */
58
-    protected function getReferences()
59
-    {
60
-        $branches = array();
61
-        // Placeholder to put master branch first
62
-        $firstBranch = null;
63
-
64
-        try {
65
-            $repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath());
66
-        } catch (Exception $e) {
67
-            return $branches;
68
-        }
69
-
70
-        foreach ($repository->getReferences()->getBranches() as $branch) {
71
-            /** @var DNBranch $obj */
72
-            $obj = DNBranch::create($branch, $this->project, $this->data);
73
-            if ($branch->getName() == 'master') {
74
-                $firstBranch = array($branch->getName() => $obj);
75
-            } else {
76
-                $branches[$branch->getName()] = $obj;
77
-            }
78
-        }
79
-        if ($firstBranch) {
80
-            $branches = $firstBranch + $branches;
81
-        }
82
-
83
-        return $branches;
84
-    }
85
-
86
-    /**
87
-     * Find a branch in this set by branch name.
88
-     *
89
-     * @param $name
90
-     *
91
-     * @return string
92
-     */
93
-    public function byName($name)
94
-    {
95
-        if ($this->loaded === false) {
96
-            $this->getIterator();
97
-        }
98
-
99
-        if (isset($this->items[$name])) {
100
-            return $this->items[$name];
101
-        }
102
-
103
-        return '';
104
-    }
105
-
106
-    /**
107
-     * Returns an Iterator for this ArrayList.
108
-     * This function allows you to use ArrayList in foreach loops
109
-     *
110
-     * @return ArrayIterator
111
-     */
112
-    public function getIterator()
113
-    {
114
-        if ($this->loaded === false) {
115
-            $this->items = $this->getReferences();
116
-            $this->loaded = true;
117
-        }
118
-        foreach ($this->items as $i => $item) {
119
-            if (is_array($item)) {
120
-                $this->items[$i] = new ArrayData($item);
121
-            }
122
-        }
123
-        return new ArrayIterator($this->items);
124
-    }
9
+	/**
10
+	 * @var string
11
+	 */
12
+	protected static $refs_dir = '';
13
+
14
+	/**
15
+	 * @var bool
16
+	 */
17
+	protected $loaded = false;
18
+
19
+	/**
20
+	 * @var array
21
+	 */
22
+	protected $builds = array();
23
+
24
+	/**
25
+	 * @var DNProject
26
+	 */
27
+	protected $project;
28
+
29
+	/**
30
+	 * @var DNData
31
+	 */
32
+	protected $data;
33
+
34
+	public static function set_refs_dir($refsDir)
35
+	{
36
+		self::$refs_dir = $refsDir;
37
+	}
38
+
39
+	public static function get_refs_dir()
40
+	{
41
+		return self::$refs_dir;
42
+	}
43
+
44
+	/**
45
+	 * @param DNProject $project
46
+	 * @param DNData $data
47
+	 */
48
+	public function __construct(DNProject $project, DNData $data)
49
+	{
50
+		$this->project = $project;
51
+		$this->data = $data;
52
+		parent::__construct(array());
53
+	}
54
+
55
+	/**
56
+	 * @return array
57
+	 */
58
+	protected function getReferences()
59
+	{
60
+		$branches = array();
61
+		// Placeholder to put master branch first
62
+		$firstBranch = null;
63
+
64
+		try {
65
+			$repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath());
66
+		} catch (Exception $e) {
67
+			return $branches;
68
+		}
69
+
70
+		foreach ($repository->getReferences()->getBranches() as $branch) {
71
+			/** @var DNBranch $obj */
72
+			$obj = DNBranch::create($branch, $this->project, $this->data);
73
+			if ($branch->getName() == 'master') {
74
+				$firstBranch = array($branch->getName() => $obj);
75
+			} else {
76
+				$branches[$branch->getName()] = $obj;
77
+			}
78
+		}
79
+		if ($firstBranch) {
80
+			$branches = $firstBranch + $branches;
81
+		}
82
+
83
+		return $branches;
84
+	}
85
+
86
+	/**
87
+	 * Find a branch in this set by branch name.
88
+	 *
89
+	 * @param $name
90
+	 *
91
+	 * @return string
92
+	 */
93
+	public function byName($name)
94
+	{
95
+		if ($this->loaded === false) {
96
+			$this->getIterator();
97
+		}
98
+
99
+		if (isset($this->items[$name])) {
100
+			return $this->items[$name];
101
+		}
102
+
103
+		return '';
104
+	}
105
+
106
+	/**
107
+	 * Returns an Iterator for this ArrayList.
108
+	 * This function allows you to use ArrayList in foreach loops
109
+	 *
110
+	 * @return ArrayIterator
111
+	 */
112
+	public function getIterator()
113
+	{
114
+		if ($this->loaded === false) {
115
+			$this->items = $this->getReferences();
116
+			$this->loaded = true;
117
+		}
118
+		foreach ($this->items as $i => $item) {
119
+			if (is_array($item)) {
120
+				$this->items[$i] = new ArrayData($item);
121
+			}
122
+		}
123
+		return new ArrayIterator($this->items);
124
+	}
125 125
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
 
64 64
         try {
65 65
             $repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath());
66
-        } catch (Exception $e) {
66
+        } catch(Exception $e) {
67 67
             return $branches;
68 68
         }
69 69
 
70
-        foreach ($repository->getReferences()->getBranches() as $branch) {
70
+        foreach($repository->getReferences()->getBranches() as $branch) {
71 71
             /** @var DNBranch $obj */
72 72
             $obj = DNBranch::create($branch, $this->project, $this->data);
73
-            if ($branch->getName() == 'master') {
73
+            if($branch->getName() == 'master') {
74 74
                 $firstBranch = array($branch->getName() => $obj);
75 75
             } else {
76 76
                 $branches[$branch->getName()] = $obj;
77 77
             }
78 78
         }
79
-        if ($firstBranch) {
79
+        if($firstBranch) {
80 80
             $branches = $firstBranch + $branches;
81 81
         }
82 82
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function byName($name)
94 94
     {
95
-        if ($this->loaded === false) {
95
+        if($this->loaded === false) {
96 96
             $this->getIterator();
97 97
         }
98 98
 
99
-        if (isset($this->items[$name])) {
99
+        if(isset($this->items[$name])) {
100 100
             return $this->items[$name];
101 101
         }
102 102
 
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function getIterator()
113 113
     {
114
-        if ($this->loaded === false) {
114
+        if($this->loaded === false) {
115 115
             $this->items = $this->getReferences();
116 116
             $this->loaded = true;
117 117
         }
118
-        foreach ($this->items as $i => $item) {
119
-            if (is_array($item)) {
118
+        foreach($this->items as $i => $item) {
119
+            if(is_array($item)) {
120 120
                 $this->items[$i] = new ArrayData($item);
121 121
             }
122 122
         }
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -3,8 +3,7 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  * Class DNBranchList
5 5
  */
6
-class DNBranchList extends ArrayList
7
-{
6
+class DNBranchList extends ArrayList {
8 7
 
9 8
     /**
10 9
      * @var string
@@ -31,13 +30,11 @@  discard block
 block discarded – undo
31 30
      */
32 31
     protected $data;
33 32
 
34
-    public static function set_refs_dir($refsDir)
35
-    {
33
+    public static function set_refs_dir($refsDir) {
36 34
         self::$refs_dir = $refsDir;
37 35
     }
38 36
 
39
-    public static function get_refs_dir()
40
-    {
37
+    public static function get_refs_dir() {
41 38
         return self::$refs_dir;
42 39
     }
43 40
 
@@ -45,8 +42,7 @@  discard block
 block discarded – undo
45 42
      * @param DNProject $project
46 43
      * @param DNData $data
47 44
      */
48
-    public function __construct(DNProject $project, DNData $data)
49
-    {
45
+    public function __construct(DNProject $project, DNData $data) {
50 46
         $this->project = $project;
51 47
         $this->data = $data;
52 48
         parent::__construct(array());
@@ -55,8 +51,7 @@  discard block
 block discarded – undo
55 51
     /**
56 52
      * @return array
57 53
      */
58
-    protected function getReferences()
59
-    {
54
+    protected function getReferences() {
60 55
         $branches = array();
61 56
         // Placeholder to put master branch first
62 57
         $firstBranch = null;
@@ -90,8 +85,7 @@  discard block
 block discarded – undo
90 85
      *
91 86
      * @return string
92 87
      */
93
-    public function byName($name)
94
-    {
88
+    public function byName($name) {
95 89
         if ($this->loaded === false) {
96 90
             $this->getIterator();
97 91
         }
@@ -109,8 +103,7 @@  discard block
 block discarded – undo
109 103
      *
110 104
      * @return ArrayIterator
111 105
      */
112
-    public function getIterator()
113
-    {
106
+    public function getIterator() {
114 107
         if ($this->loaded === false) {
115 108
             $this->items = $this->getReferences();
116 109
             $this->loaded = true;
Please login to merge, or discard this patch.
code/model/DNCommit.php 3 patches
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -2,220 +2,220 @@
 block discarded – undo
2 2
 class DNCommit extends ViewableData
3 3
 {
4 4
 
5
-    /**
6
-     * @var Gitonomy\Git\Commit
7
-     */
8
-    protected $commit = null;
9
-
10
-    protected $name = null;
11
-
12
-
13
-    protected $references = null;
14
-
15
-    /**
16
-     * @var string
17
-     */
18
-    protected $ownerBranchName = null;
19
-
20
-    /**
21
-     * @var string
22
-     */
23
-    protected $buildname;
24
-
25
-    /**
26
-     * @var DNProject
27
-     */
28
-    protected $project;
29
-
30
-    /**
31
-     * @var DNData
32
-     */
33
-    protected $data;
34
-
35
-    /**
36
-     * @var string
37
-     */
38
-    protected $subjectMessage;
39
-
40
-    /**
41
-     * @var string
42
-     */
43
-    protected $bodyMessage;
44
-
45
-    /**
46
-     * @var array
47
-     */
48
-    private static $casting = array(
49
-        'Name' => 'Text',
50
-        'SubjectMessage' => 'Text',
51
-        'Message' => 'Text',
52
-        'BodyMessage' => 'Text',
53
-        'Fullname' => 'Text',
54
-        'Filename' => 'Text',
55
-        'References' => 'Text',
56
-        'ownerBranchName' => 'Text'
57
-    );
58
-
59
-    /**
60
-     * @param Gitonomy\Git\Commit $commit
61
-     * @param DNProject $project
62
-     * @param DNData $data
63
-     * @param string|null $ownerBranchName
64
-     */
65
-    public function __construct(Gitonomy\Git\Commit $commit, DNProject $project, DNData $data, $ownerBranchName = null)
66
-    {
67
-        $this->commit = $commit;
68
-        $this->buildname = $commit->getHash();
69
-        $this->project = $project;
70
-        $this->data = $data;
71
-        $this->ownerBranchName = $ownerBranchName;
72
-    }
73
-
74
-    /**
75
-     * Return the hash of the commit, used to name this commit.
76
-     * @return string
77
-     */
78
-    public function Name()
79
-    {
80
-        if ($this->name == null) {
81
-            $this->name = $this->commit->getFixedShortHash(8);
82
-        }
83
-
84
-        return htmlentities($this->name);
85
-    }
86
-
87
-    /**
88
-     * Return the full SHA of the commit.
89
-     * @return string
90
-     */
91
-    public function SHA()
92
-    {
93
-        return htmlentities($this->commit->getHash());
94
-    }
95
-
96
-    /**
97
-     * Return the first line of the commit message.
98
-     * @return string
99
-     */
100
-    public function SubjectMessage()
101
-    {
102
-        if ($this->subjectMessage == null) {
103
-            $this->subjectMessage = $this->commit->getSubjectMessage();
104
-        }
105
-
106
-        return htmlentities($this->subjectMessage);
107
-    }
108
-
109
-    public function BodyMessage()
110
-    {
111
-        if ($this->bodyMessage == null) {
112
-            $this->bodyMessage = $this->commit->getBodyMessage();
113
-        }
114
-
115
-        return htmlentities($this->bodyMessage);
116
-    }
117
-
118
-    /**
119
-     * @return ArrayList
120
-     */
121
-    public function References()
122
-    {
123
-        if ($this->references !== null) {
124
-            return $this->references;
125
-        }
126
-        $this->references = new ArrayList();
127
-
128
-        // Add tags
129
-        foreach ($this->commit->resolveReferences() as $reference) {
130
-            if ($reference instanceof \Gitonomy\Git\Reference\Tag) {
131
-                $this->references->push(new ArrayData(array(
132
-                    'Name' => $reference->getName(),
133
-                    'Type' => 'Tag',
134
-                )));
135
-            }
136
-        }
137
-
138
-        return $this->references;
139
-    }
140
-
141
-    /**
142
-     * @return string
143
-     */
144
-    public function FullName()
145
-    {
146
-        return htmlentities($this->commit->getHash());
147
-    }
148
-
149
-    /**
150
-     * @return string
151
-     */
152
-    public function Filename()
153
-    {
154
-        return htmlentities($this->commit->getHash());
155
-    }
156
-
157
-    /**
158
-     * @return ArrayList
159
-     */
160
-    public function CurrentlyDeployedTo()
161
-    {
162
-        $environments = $this->project->Environments();
163
-        $envList = new ArrayList();
164
-        foreach ($environments as $environment) {
165
-            $deployments = DNDeployment::get()
166
-                ->filter('Status', 'Finished')
167
-                ->filter('EnvironmentID', $environment->ID)
168
-                ->sort('LastEdited DESC');
169
-            if (!$deployments->count()) {
170
-                continue;
171
-            }
172
-            $latest = $deployments->first();
173
-            if ($latest->SHA === $this->commit->getHash()) {
174
-                $envList->push($environment);
175
-            }
176
-        }
177
-        return $envList;
178
-    }
179
-
180
-    /**
181
-     * @param string $environmentName
182
-     * @return boolean True if this release has ever been deployed to the given environment
183
-     */
184
-    public function EverDeployedTo($environmentName)
185
-    {
186
-        $environments = $this->project->Environments()->filter('Name', $environmentName);
187
-        if (!$environments->count()) {
188
-            return false;
189
-        }
190
-
191
-        $environment = $environments->first();
192
-
193
-        $deployments = DNDeployment::get()
194
-                ->filter('Status', 'Finished')
195
-                ->filter('EnvironmentID', $environment->ID);
196
-
197
-        if ($deployments->count()) {
198
-            return true;
199
-        }
200
-
201
-        return false;
202
-    }
203
-
204
-    /**
205
-     * @return SS_Datetime
206
-     */
207
-    public function Created()
208
-    {
209
-        $created = $this->commit->getCommitterDate();
210
-
211
-        // gitonomy sets the time to UTC, so now we set the timezone to
212
-        // whatever PHP is set to (date.timezone). This will change in the future if each
213
-        // deploynaut user has their own timezone
214
-        $created->setTimezone(new DateTimeZone(date_default_timezone_get()));
215
-
216
-        $d = new SS_Datetime();
217
-        $d->setValue($created->format('Y-m-d H:i:s'));
218
-
219
-        return $d;
220
-    }
5
+	/**
6
+	 * @var Gitonomy\Git\Commit
7
+	 */
8
+	protected $commit = null;
9
+
10
+	protected $name = null;
11
+
12
+
13
+	protected $references = null;
14
+
15
+	/**
16
+	 * @var string
17
+	 */
18
+	protected $ownerBranchName = null;
19
+
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected $buildname;
24
+
25
+	/**
26
+	 * @var DNProject
27
+	 */
28
+	protected $project;
29
+
30
+	/**
31
+	 * @var DNData
32
+	 */
33
+	protected $data;
34
+
35
+	/**
36
+	 * @var string
37
+	 */
38
+	protected $subjectMessage;
39
+
40
+	/**
41
+	 * @var string
42
+	 */
43
+	protected $bodyMessage;
44
+
45
+	/**
46
+	 * @var array
47
+	 */
48
+	private static $casting = array(
49
+		'Name' => 'Text',
50
+		'SubjectMessage' => 'Text',
51
+		'Message' => 'Text',
52
+		'BodyMessage' => 'Text',
53
+		'Fullname' => 'Text',
54
+		'Filename' => 'Text',
55
+		'References' => 'Text',
56
+		'ownerBranchName' => 'Text'
57
+	);
58
+
59
+	/**
60
+	 * @param Gitonomy\Git\Commit $commit
61
+	 * @param DNProject $project
62
+	 * @param DNData $data
63
+	 * @param string|null $ownerBranchName
64
+	 */
65
+	public function __construct(Gitonomy\Git\Commit $commit, DNProject $project, DNData $data, $ownerBranchName = null)
66
+	{
67
+		$this->commit = $commit;
68
+		$this->buildname = $commit->getHash();
69
+		$this->project = $project;
70
+		$this->data = $data;
71
+		$this->ownerBranchName = $ownerBranchName;
72
+	}
73
+
74
+	/**
75
+	 * Return the hash of the commit, used to name this commit.
76
+	 * @return string
77
+	 */
78
+	public function Name()
79
+	{
80
+		if ($this->name == null) {
81
+			$this->name = $this->commit->getFixedShortHash(8);
82
+		}
83
+
84
+		return htmlentities($this->name);
85
+	}
86
+
87
+	/**
88
+	 * Return the full SHA of the commit.
89
+	 * @return string
90
+	 */
91
+	public function SHA()
92
+	{
93
+		return htmlentities($this->commit->getHash());
94
+	}
95
+
96
+	/**
97
+	 * Return the first line of the commit message.
98
+	 * @return string
99
+	 */
100
+	public function SubjectMessage()
101
+	{
102
+		if ($this->subjectMessage == null) {
103
+			$this->subjectMessage = $this->commit->getSubjectMessage();
104
+		}
105
+
106
+		return htmlentities($this->subjectMessage);
107
+	}
108
+
109
+	public function BodyMessage()
110
+	{
111
+		if ($this->bodyMessage == null) {
112
+			$this->bodyMessage = $this->commit->getBodyMessage();
113
+		}
114
+
115
+		return htmlentities($this->bodyMessage);
116
+	}
117
+
118
+	/**
119
+	 * @return ArrayList
120
+	 */
121
+	public function References()
122
+	{
123
+		if ($this->references !== null) {
124
+			return $this->references;
125
+		}
126
+		$this->references = new ArrayList();
127
+
128
+		// Add tags
129
+		foreach ($this->commit->resolveReferences() as $reference) {
130
+			if ($reference instanceof \Gitonomy\Git\Reference\Tag) {
131
+				$this->references->push(new ArrayData(array(
132
+					'Name' => $reference->getName(),
133
+					'Type' => 'Tag',
134
+				)));
135
+			}
136
+		}
137
+
138
+		return $this->references;
139
+	}
140
+
141
+	/**
142
+	 * @return string
143
+	 */
144
+	public function FullName()
145
+	{
146
+		return htmlentities($this->commit->getHash());
147
+	}
148
+
149
+	/**
150
+	 * @return string
151
+	 */
152
+	public function Filename()
153
+	{
154
+		return htmlentities($this->commit->getHash());
155
+	}
156
+
157
+	/**
158
+	 * @return ArrayList
159
+	 */
160
+	public function CurrentlyDeployedTo()
161
+	{
162
+		$environments = $this->project->Environments();
163
+		$envList = new ArrayList();
164
+		foreach ($environments as $environment) {
165
+			$deployments = DNDeployment::get()
166
+				->filter('Status', 'Finished')
167
+				->filter('EnvironmentID', $environment->ID)
168
+				->sort('LastEdited DESC');
169
+			if (!$deployments->count()) {
170
+				continue;
171
+			}
172
+			$latest = $deployments->first();
173
+			if ($latest->SHA === $this->commit->getHash()) {
174
+				$envList->push($environment);
175
+			}
176
+		}
177
+		return $envList;
178
+	}
179
+
180
+	/**
181
+	 * @param string $environmentName
182
+	 * @return boolean True if this release has ever been deployed to the given environment
183
+	 */
184
+	public function EverDeployedTo($environmentName)
185
+	{
186
+		$environments = $this->project->Environments()->filter('Name', $environmentName);
187
+		if (!$environments->count()) {
188
+			return false;
189
+		}
190
+
191
+		$environment = $environments->first();
192
+
193
+		$deployments = DNDeployment::get()
194
+				->filter('Status', 'Finished')
195
+				->filter('EnvironmentID', $environment->ID);
196
+
197
+		if ($deployments->count()) {
198
+			return true;
199
+		}
200
+
201
+		return false;
202
+	}
203
+
204
+	/**
205
+	 * @return SS_Datetime
206
+	 */
207
+	public function Created()
208
+	{
209
+		$created = $this->commit->getCommitterDate();
210
+
211
+		// gitonomy sets the time to UTC, so now we set the timezone to
212
+		// whatever PHP is set to (date.timezone). This will change in the future if each
213
+		// deploynaut user has their own timezone
214
+		$created->setTimezone(new DateTimeZone(date_default_timezone_get()));
215
+
216
+		$d = new SS_Datetime();
217
+		$d->setValue($created->format('Y-m-d H:i:s'));
218
+
219
+		return $d;
220
+	}
221 221
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function Name()
79 79
     {
80
-        if ($this->name == null) {
80
+        if($this->name == null) {
81 81
             $this->name = $this->commit->getFixedShortHash(8);
82 82
         }
83 83
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function SubjectMessage()
101 101
     {
102
-        if ($this->subjectMessage == null) {
102
+        if($this->subjectMessage == null) {
103 103
             $this->subjectMessage = $this->commit->getSubjectMessage();
104 104
         }
105 105
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
     public function BodyMessage()
110 110
     {
111
-        if ($this->bodyMessage == null) {
111
+        if($this->bodyMessage == null) {
112 112
             $this->bodyMessage = $this->commit->getBodyMessage();
113 113
         }
114 114
 
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function References()
122 122
     {
123
-        if ($this->references !== null) {
123
+        if($this->references !== null) {
124 124
             return $this->references;
125 125
         }
126 126
         $this->references = new ArrayList();
127 127
 
128 128
         // Add tags
129
-        foreach ($this->commit->resolveReferences() as $reference) {
130
-            if ($reference instanceof \Gitonomy\Git\Reference\Tag) {
129
+        foreach($this->commit->resolveReferences() as $reference) {
130
+            if($reference instanceof \Gitonomy\Git\Reference\Tag) {
131 131
                 $this->references->push(new ArrayData(array(
132 132
                     'Name' => $reference->getName(),
133 133
                     'Type' => 'Tag',
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
     {
162 162
         $environments = $this->project->Environments();
163 163
         $envList = new ArrayList();
164
-        foreach ($environments as $environment) {
164
+        foreach($environments as $environment) {
165 165
             $deployments = DNDeployment::get()
166 166
                 ->filter('Status', 'Finished')
167 167
                 ->filter('EnvironmentID', $environment->ID)
168 168
                 ->sort('LastEdited DESC');
169
-            if (!$deployments->count()) {
169
+            if(!$deployments->count()) {
170 170
                 continue;
171 171
             }
172 172
             $latest = $deployments->first();
173
-            if ($latest->SHA === $this->commit->getHash()) {
173
+            if($latest->SHA === $this->commit->getHash()) {
174 174
                 $envList->push($environment);
175 175
             }
176 176
         }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
     public function EverDeployedTo($environmentName)
185 185
     {
186 186
         $environments = $this->project->Environments()->filter('Name', $environmentName);
187
-        if (!$environments->count()) {
187
+        if(!$environments->count()) {
188 188
             return false;
189 189
         }
190 190
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                 ->filter('Status', 'Finished')
195 195
                 ->filter('EnvironmentID', $environment->ID);
196 196
 
197
-        if ($deployments->count()) {
197
+        if($deployments->count()) {
198 198
             return true;
199 199
         }
200 200
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class DNCommit extends ViewableData
3
-{
2
+class DNCommit extends ViewableData {
4 3
 
5 4
     /**
6 5
      * @var Gitonomy\Git\Commit
@@ -62,8 +61,7 @@  discard block
 block discarded – undo
62 61
      * @param DNData $data
63 62
      * @param string|null $ownerBranchName
64 63
      */
65
-    public function __construct(Gitonomy\Git\Commit $commit, DNProject $project, DNData $data, $ownerBranchName = null)
66
-    {
64
+    public function __construct(Gitonomy\Git\Commit $commit, DNProject $project, DNData $data, $ownerBranchName = null) {
67 65
         $this->commit = $commit;
68 66
         $this->buildname = $commit->getHash();
69 67
         $this->project = $project;
@@ -75,8 +73,7 @@  discard block
 block discarded – undo
75 73
      * Return the hash of the commit, used to name this commit.
76 74
      * @return string
77 75
      */
78
-    public function Name()
79
-    {
76
+    public function Name() {
80 77
         if ($this->name == null) {
81 78
             $this->name = $this->commit->getFixedShortHash(8);
82 79
         }
@@ -88,8 +85,7 @@  discard block
 block discarded – undo
88 85
      * Return the full SHA of the commit.
89 86
      * @return string
90 87
      */
91
-    public function SHA()
92
-    {
88
+    public function SHA() {
93 89
         return htmlentities($this->commit->getHash());
94 90
     }
95 91
 
@@ -97,8 +93,7 @@  discard block
 block discarded – undo
97 93
      * Return the first line of the commit message.
98 94
      * @return string
99 95
      */
100
-    public function SubjectMessage()
101
-    {
96
+    public function SubjectMessage() {
102 97
         if ($this->subjectMessage == null) {
103 98
             $this->subjectMessage = $this->commit->getSubjectMessage();
104 99
         }
@@ -106,8 +101,7 @@  discard block
 block discarded – undo
106 101
         return htmlentities($this->subjectMessage);
107 102
     }
108 103
 
109
-    public function BodyMessage()
110
-    {
104
+    public function BodyMessage() {
111 105
         if ($this->bodyMessage == null) {
112 106
             $this->bodyMessage = $this->commit->getBodyMessage();
113 107
         }
@@ -118,8 +112,7 @@  discard block
 block discarded – undo
118 112
     /**
119 113
      * @return ArrayList
120 114
      */
121
-    public function References()
122
-    {
115
+    public function References() {
123 116
         if ($this->references !== null) {
124 117
             return $this->references;
125 118
         }
@@ -141,24 +134,21 @@  discard block
 block discarded – undo
141 134
     /**
142 135
      * @return string
143 136
      */
144
-    public function FullName()
145
-    {
137
+    public function FullName() {
146 138
         return htmlentities($this->commit->getHash());
147 139
     }
148 140
 
149 141
     /**
150 142
      * @return string
151 143
      */
152
-    public function Filename()
153
-    {
144
+    public function Filename() {
154 145
         return htmlentities($this->commit->getHash());
155 146
     }
156 147
 
157 148
     /**
158 149
      * @return ArrayList
159 150
      */
160
-    public function CurrentlyDeployedTo()
161
-    {
151
+    public function CurrentlyDeployedTo() {
162 152
         $environments = $this->project->Environments();
163 153
         $envList = new ArrayList();
164 154
         foreach ($environments as $environment) {
@@ -181,8 +171,7 @@  discard block
 block discarded – undo
181 171
      * @param string $environmentName
182 172
      * @return boolean True if this release has ever been deployed to the given environment
183 173
      */
184
-    public function EverDeployedTo($environmentName)
185
-    {
174
+    public function EverDeployedTo($environmentName) {
186 175
         $environments = $this->project->Environments()->filter('Name', $environmentName);
187 176
         if (!$environments->count()) {
188 177
             return false;
@@ -204,8 +193,7 @@  discard block
 block discarded – undo
204 193
     /**
205 194
      * @return SS_Datetime
206 195
      */
207
-    public function Created()
208
-    {
196
+    public function Created() {
209 197
         $created = $this->commit->getCommitterDate();
210 198
 
211 199
         // gitonomy sets the time to UTC, so now we set the timezone to
Please login to merge, or discard this patch.