-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
125 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cmd | ||
|
||
import ( | ||
"git.kausm.in/kaustubh/autosaved/core" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var restoreCmd = &cobra.Command{ | ||
Use: "restore commit-hash", | ||
Short: "Restores the state of a repository to a previous checkpoint (commit). Input is commit hash that we want to restore", | ||
Long: `Restores the state of the repository to a previous state, | ||
whose commit Hash is given as an argument`, | ||
Args: cobra.ExactArgs(1), | ||
Run: restore, | ||
} | ||
|
||
func restore(cmd *cobra.Command, args []string) { | ||
repoPath := "." | ||
asdRepo, err := core.AsdRepoFromGitRepoPath(repoPath, getMinSeconds()) | ||
checkError(err) | ||
|
||
hashString := args[0] | ||
|
||
err = asdRepo.RestoreByCommitHash(hashString) | ||
checkError(err) | ||
|
||
asdFmt.Successf("Restored successfully\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters