Skip to content

Commit

Permalink
Add reset
Browse files Browse the repository at this point in the history
  • Loading branch information
guillep committed Apr 6, 2018
1 parent f9b9bd7 commit 667fd60
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ checkout: aString options: options
self assert: aString notNil.
self assert: aString trimBoth notEmpty.
[

| branch |
branch := self
lookupLocalBranch: aString
ifAbsent: [ self createBranchFromOrigin: aString ].

self checkout_treeish: branch object opts: options.
self setHead: branch.
self resetHardTo: branch object checkoutOptions: options
]
on: LGit_GIT_EINVALIDSPEC, LGit_GIT_ENOTFOUND do: [
"aString is not a valid branch name, so try to find a corresponding treeish using revparse,
this will handle stuff like 'master~1'"
| commitish |
commitish := self revparse: aString.
self checkout_treeish: commitish.
self setHeadDetached: commitish.
self setHead: commitish.
self resetHardTo: commitish object checkoutOptions: options.
].

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
libgit-calls
resetHardTo: target

^ self
resetHardTo: target
checkoutOptions: (LGitCheckoutOptions defaults
checkoutStrategy: LGitCheckoutStrategyEnum git_checkout_force;
yourself)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
libgit-calls
resetHardTo: target checkoutOptions: options

^ self
resetTo: target
resetType: LGitResetTypeEnum git_reset_hard
checkoutOptions: options
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
libgit-calls
resetTo: target resetType: aResetType checkoutOptions: checkout_opts

^ self
call: #(LGitReturnCodeEnum git_reset(self, LGitObject target, LGitResetTypeEnum aResetType, LGitCheckoutOptions *checkout_opts))
options: #()
Empty file.
7 changes: 7 additions & 0 deletions LibGit-Core.package/LGitResetTypeEnum.class/class/enumDecl.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enum declaration
enumDecl
^ #(
GIT_RESET_SOFT 1 "Move the head to the given commit"
GIT_RESET_MIXED 2 "SOFT plus reset index to the commit"
GIT_RESET_HARD 3 "MIXED plus changes in working tree discarded"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing-values
git_reset_hard
^ self basicNew
value: 3;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing-values
git_reset_mixed
^ self basicNew
value: 2;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing-values
git_reset_soft
^ self basicNew
value: 1;
yourself
11 changes: 11 additions & 0 deletions LibGit-Core.package/LGitResetTypeEnum.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "LGitExternalEnumerationUInt32",
"category" : "LibGit-Core-FFI-Enums",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "LGitResetTypeEnum",
"type" : "normal"
}

0 comments on commit 667fd60

Please sign in to comment.