@@ -1096,3 +1096,94 @@ def help(
10961096 local_flags .append ("--web" )
10971097
10981098 return self .run (["help" , * local_flags ], check_returncode = False )
1099+
1100+ def reset (
1101+ self ,
1102+ quiet : Optional [bool ] = None ,
1103+ refresh : Optional [bool ] = None ,
1104+ no_refresh : Optional [bool ] = None ,
1105+ pathspec_from_file : Optional [StrOrBytesPath ] = None ,
1106+ pathspec : Optional [Union [StrOrBytesPath , list [StrOrBytesPath ]]] = None ,
1107+ soft : Optional [bool ] = None ,
1108+ mixed : Optional [bool ] = None ,
1109+ hard : Optional [bool ] = None ,
1110+ merge : Optional [bool ] = None ,
1111+ keep : Optional [bool ] = None ,
1112+ commit : Optional [str ] = None ,
1113+ recurse_submodules : Optional [bool ] = None ,
1114+ no_recurse_submodules : Optional [bool ] = None ,
1115+ ** kwargs ,
1116+ ):
1117+ """Reset HEAD. Wraps `git help <https://git-scm.com/docs/git-help>`_.
1118+
1119+ Parameters
1120+ ----------
1121+ quiet : bool
1122+ no_refresh : bool
1123+ refresh : bool
1124+ pathspec_from_file : :attr:`libvcs.cmd.types.StrOrBytesPath`
1125+ pathspec_file_nul : bool
1126+ pathspec : :attr:`libvcs.cmd.types.StrOrBytesPath` or list
1127+ :attr:`libvcs.cmd.types.StrOrBytesPath`
1128+ soft : bool
1129+ mixed : bool
1130+ hard : bool
1131+ merge : bool
1132+ keep : bool
1133+ commit : str
1134+
1135+ Examples
1136+ --------
1137+ >>> git = Git(dir=git_local_clone.dir)
1138+
1139+ >>> git.reset()
1140+ ''
1141+
1142+ >>> git.reset(soft=True, commit='HEAD~1')
1143+ ''
1144+ """
1145+ local_flags : list [str ] = []
1146+
1147+ if quiet is True :
1148+ local_flags .append ("--quiet" )
1149+ if no_refresh is True :
1150+ local_flags .append ("--no-refresh" )
1151+ if refresh is True :
1152+ local_flags .append ("--refresh" )
1153+ if pathspec_from_file is True :
1154+ local_flags .append (f"--pathspec_from_file { pathspec_from_file } " )
1155+
1156+ # HEAD to commit form
1157+ if soft is True :
1158+ local_flags .append ("--soft" )
1159+
1160+ if mixed is True :
1161+ local_flags .append ("--mixed" )
1162+
1163+ if hard is True :
1164+ local_flags .append ("--hard" )
1165+
1166+ if merge is True :
1167+ local_flags .append ("--merge" )
1168+
1169+ if keep is True :
1170+ local_flags .append ("--keep" )
1171+
1172+ if commit is True :
1173+ local_flags .append (f"{ commit } " )
1174+
1175+ if recurse_submodules :
1176+ local_flags .append ("--recurse-submodules" )
1177+ elif no_recurse_submodules :
1178+ local_flags .append ("--no-recurse-submodules" )
1179+
1180+ if pathspec is not None :
1181+ if not isinstance (pathspec , list ):
1182+ pathspec = [pathspec ]
1183+ else :
1184+ pathspec = []
1185+
1186+ return self .run (
1187+ ["reset" , * local_flags , * (["--" , * pathspec ] if len (pathspec ) else [])],
1188+ check_returncode = False ,
1189+ )
0 commit comments