| @@ 35-53 (lines=19) @@ | ||
| 32 | * |
|
| 33 | * @return string|WP_Error |
|
| 34 | */ |
|
| 35 | public function payload( Writing_On_GitHub_Payload $payload ) { |
|
| 36 | ||
| 37 | $result = $this->app->api()->fetch()->compare( $payload->get_before_commit_id() ); |
|
| 38 | ||
| 39 | if ( is_wp_error( $result ) ) { |
|
| 40 | /* @var WP_Error $result */ |
|
| 41 | return $result; |
|
| 42 | } |
|
| 43 | ||
| 44 | if ( is_array( $result ) ) { |
|
| 45 | $result = $this->import_files( $result ); |
|
| 46 | } |
|
| 47 | ||
| 48 | if ( is_wp_error( $result ) ) { |
|
| 49 | return $files; |
|
| 50 | } |
|
| 51 | ||
| 52 | return __( 'Payload processed', 'writing-on-github' ); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * import blob by files |
|
| @@ 103-121 (lines=19) @@ | ||
| 100 | * |
|
| 101 | * @return string|WP_Error |
|
| 102 | */ |
|
| 103 | public function master() { |
|
| 104 | $result = $this->app->api()->fetch()->tree_recursive(); |
|
| 105 | ||
| 106 | if ( is_wp_error( $result ) ) { |
|
| 107 | /* @var WP_Error $result */ |
|
| 108 | return $result; |
|
| 109 | } |
|
| 110 | ||
| 111 | if ( is_array( $result ) ) { |
|
| 112 | $result = $this->import_files( $result ); |
|
| 113 | } |
|
| 114 | ||
| 115 | if ( is_wp_error( $result ) ) { |
|
| 116 | /* @var WP_Error $result */ |
|
| 117 | return $result; |
|
| 118 | } |
|
| 119 | ||
| 120 | return __( 'Payload processed', 'writing-on-github' ); |
|
| 121 | } |
|
| 122 | ||
| 123 | /** |
|
| 124 | * Checks whether the provided blob should be imported. |
|