Last active
August 21, 2019 04:26
-
-
Save exavolt/9422ed9ae07c766149c4a9ed831a29f8 to your computer and use it in GitHub Desktop.
Revisions
-
exavolt revised this gist
Aug 21, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -37,6 +37,7 @@ func main() { } if commit == nil { break } if len(commit.ParentHashes) > 1 { continue } -
exavolt revised this gist
Aug 21, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -35,6 +35,8 @@ func main() { if err != nil { panic(err) } if commit == nil { break if len(commit.ParentHashes) > 1 { continue } -
exavolt created this gist
Aug 21, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ package main import ( "fmt" "path/filepath" "strings" "gopkg.in/src-d/go-billy.v4/osfs" "gopkg.in/src-d/go-git.v4" "gopkg.in/src-d/go-git.v4/plumbing/cache" "gopkg.in/src-d/go-git.v4/plumbing/object" "gopkg.in/src-d/go-git.v4/storage/filesystem" ) func main() { targetCount := 20 workingDirectory := "." gitDotFS := osfs.New(filepath.Join(workingDirectory, ".git")) gitWorkingDirFS := osfs.New(workingDirectory) objectCache := cache.NewObjectLRUDefault() gitStorage := filesystem.NewStorage(gitDotFS, objectCache) gitRepo, err := git.Open(gitStorage, gitWorkingDirFS) if err != nil { panic(err) } commitIter, err := gitRepo.Log(&git.LogOptions{ Order: git.LogOrderBSF, }) if err != nil { panic(err) } var commits []object.Commit for i := 0; i < targetCount; { commit, err := commitIter.Next() if err != nil { panic(err) } if len(commit.ParentHashes) > 1 { continue } commits = append(commits, *commit) i++ } for i := 0; i < targetCount; i++ { commit := commits[i] msg := strings.SplitN(commit.Message, "\n", 2)[0] fmt.Printf("- %v\n", msg) } }