diff --git a/Web/lib/MJB/Web/Controller/Dashboard.pm b/Web/lib/MJB/Web/Controller/Dashboard.pm index 4435c18..bf0bf82 100644 --- a/Web/lib/MJB/Web/Controller/Dashboard.pm +++ b/Web/lib/MJB/Web/Controller/Dashboard.pm @@ -382,11 +382,11 @@ sub do_blog_history ( $c ) { my ( $old_commit ) = grep { $_->{commit} eq $commit } @{$history}; if ( $old_commit ) { - $jekyll->revert_commit( $commit ); + $jekyll->restore_commit( $commit ); $c->sync_blog( $blog ); - $c->flash( confirmation => "Undid $commit!" ); + $c->flash( confirmation => "Restored from $commit!" ); $c->redirect_to( $c->url_for( 'show_dashboard_blog_history', { id => $blog->id } ) ); } } diff --git a/Web/templates/blog/domain_hosted.html.ep b/Web/templates/blog/domain_hosted.html.ep index ed3de6a..58230c7 100644 --- a/Web/templates/blog/domain_hosted.html.ep +++ b/Web/templates/blog/domain_hosted.html.ep @@ -35,7 +35,7 @@ . diff --git a/Web/templates/dashboard/blog_history.html.ep b/Web/templates/dashboard/blog_history.html.ep index 6334ed2..35d2ed0 100644 --- a/Web/templates/dashboard/blog_history.html.ep +++ b/Web/templates/dashboard/blog_history.html.ep @@ -21,7 +21,7 @@
- +
diff --git a/libs/MJB-Backend-Jekyll/lib/MJB/Backend/Jekyll.pm b/libs/MJB-Backend-Jekyll/lib/MJB/Backend/Jekyll.pm index b812f0f..5c57493 100644 --- a/libs/MJB-Backend-Jekyll/lib/MJB/Backend/Jekyll.pm +++ b/libs/MJB-Backend-Jekyll/lib/MJB/Backend/Jekyll.pm @@ -368,6 +368,31 @@ sub revert_commit { } +sub restore_commit { + my ( $self, $commit ) = @_; + + # Check that the repo exists and is latest. + $self->_ensure_repository_is_latest; + + # Restore the commit. + $self->system_command( [ qw( git restore --source ), $commit, qw( -W -S --theirs :/ ) ], { + chdir => $self->repo_path, + }); + + # Restore the commit. + $self->system_command( [ qw( git commit -m ), "Restored from $commit" ], { + chdir => $self->repo_path, + }); + + # Push the repo to the store server + $self->system_command( [ qw( git push origin master ) ], { + chdir => $self->repo_path, + }); + + return 1; + +} + sub delete_post { my ( $self, $title, $file ) = @_;