@@ -55,10 +55,11 @@ public function payload( Writing_On_GitHub_Payload $payload ) {
5555 /**
5656 * import blob by files
5757 * @param Writing_On_GitHub_File_Info[] $files
58+ * @param boolean $force
5859 *
5960 * @return true|WP_Error
6061 */
61- protected function import_files ( $ files ) {
62+ protected function import_files ( $ files, $ force = false ) {
6263
6364 $ error = true ;
6465
@@ -82,7 +83,7 @@ protected function import_files( $files ) {
8283 if ( $ is_remove ) {
8384 $ result = $ this ->delete_post ( $ blob );
8485 } else {
85- $ result = $ this ->import_post ( $ blob );
86+ $ result = $ this ->import_post ( $ blob, $ force );
8687 }
8788 }
8889
@@ -98,9 +99,10 @@ protected function import_files( $files ) {
9899 /**
99100 * Imports the latest commit on the master branch.
100101 *
102+ * @param boolean $force
101103 * @return string|WP_Error
102104 */
103- public function master () {
105+ public function master ( $ force = false ) {
104106 $ result = $ this ->app ->api ()->fetch ()->tree_recursive ();
105107
106108 if ( is_wp_error ( $ result ) ) {
@@ -109,7 +111,7 @@ public function master() {
109111 }
110112
111113 if ( is_array ( $ result ) ) {
112- $ result = $ this ->import_files ( $ result );
114+ $ result = $ this ->import_files ( $ result, $ force );
113115 }
114116
115117 if ( is_wp_error ( $ result ) ) {
@@ -189,10 +191,11 @@ protected function delete_post( Writing_On_GitHub_Blob $blob ) {
189191 /**
190192 * Imports a post into wordpress
191193 * @param Writing_On_GitHub_Blob $blob
194+ * @param boolean $force
192195 * @return WP_Error|bool
193196 */
194- protected function import_post ( Writing_On_GitHub_Blob $ blob ) {
195- $ post = $ this ->blob_to_post ( $ blob );
197+ protected function import_post ( Writing_On_GitHub_Blob $ blob, $ force = false ) {
198+ $ post = $ this ->blob_to_post ( $ blob, $ force );
196199
197200 if ( ! $ post instanceof Writing_On_GitHub_Post ) {
198201 return false ;
@@ -265,10 +268,11 @@ protected function import_raw_file( Writing_On_GitHub_Blob $blob, $is_remove ) {
265268 * Imports a single blob content into matching post.
266269 *
267270 * @param Writing_On_GitHub_Blob $blob Blob to transform into a Post.
271+ * @param boolean $force
268272 *
269273 * @return Writing_On_GitHub_Post|false
270274 */
271- protected function blob_to_post ( Writing_On_GitHub_Blob $ blob ) {
275+ protected function blob_to_post ( Writing_On_GitHub_Blob $ blob, $ force = false ) {
272276 $ args = array ( 'post_content ' => $ blob ->content_import () );
273277 $ meta = $ blob ->meta ();
274278
@@ -304,7 +308,7 @@ protected function blob_to_post( Writing_On_GitHub_Blob $blob ) {
304308
305309 $ meta ['_wogh_sha ' ] = $ blob ->sha ();
306310
307- if ( $ id ) {
311+ if ( ! $ force && $ id ) {
308312 $ old_sha = get_post_meta ( $ id , '_wogh_sha ' , true );
309313 $ old_github_path = get_post_meta ( $ id , '_wogh_github_path ' , true );
310314
0 commit comments