Groovy use git reset on specific branch -
i return last commit of branches , search author, if equal use git reset. modify code - remove commit of specific author, not on branches, on branch point packid.
string packid = "value operate" // value branch def equal() { git git = git.open(new file("c:\\users\\john\\test")) resetcommand resetcommand = git.reset() // git reset string author = "john doe" string excludeauthorscommit = author // name of author looking resetcommand.setmode(resetcommand.resettype.hard) // git reset --hard head~1 list<ref> branches = git.branchlist().setlistmode(listbranchcommand.listmode.all).call() // take list branches revwalk revwalk = new revwalk(git.repository) revcommit lastcommit = branches.collect { branch -> revwalk.parsecommit(branch.objectid) } .sort { commit -> commit.authorident.when } .reverse() .first() if (lastcommit.authorident.name == excludeauthorscommit) { //resetcommand.call() // if author equal excludeauthorscommit, use git reset } }
Comments
Post a Comment