Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try: retrieve last commit date and update it #194

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ protected function get_existing_for_post( WP_Post $post ) {
return array( $key, $data );
}


/**
* Get the latest commit date for a given repo.
*
* @param string $url URL to the manifest.
* @return string Date of latest commit.
*/
public function get_latest_commit_date( $url ) {
// Fetch information using the GitHub API
$latest_commit = wp_remote_get( $url );
}

/**
* Import the manifest.
*
Expand Down Expand Up @@ -130,6 +142,9 @@ public function import_manifest() {
return new WP_Error( 'invalid-manifest', 'Manifest did not unfurl properly.' );
}

$latest_commit_date = $this->get_latest_commit_date($this->get_manifest_url());
$last_update_date = get_option('last_update_date');

// A numeric key suggests the manifest did not explicitly specify keys for each item, so define one.
// Note: not explicitly specifying a key means the slugs defined must be unique.
$keys = array_keys( $manifest );
Expand Down Expand Up @@ -186,6 +201,10 @@ public function import_manifest() {
if ( $this->process_manifest_doc( $doc, $manifest ) ) {
$created++;
}

if ( $latest_commit_date > $last_update_date && $updated > 0 ) {
update_option( 'last_update_date', $latest_commit_date );
}
}
if ( class_exists( 'WP_CLI' ) ) {
if ( 0 === $created && 0 === $updated ) {
Expand Down