File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+ "os"
6
+
7
+ git "github.com/go-git/go-git/v5"
8
+ . "github.com/go-git/go-git/v5/_examples"
9
+ "github.com/go-git/go-git/v5/plumbing/transport/ssh"
10
+ )
11
+
12
+ func main () {
13
+ CheckArgs ("<url>" , "<directory>" )
14
+ url , directory := os .Args [1 ], os .Args [2 ]
8000
15
+
16
+ authMethod , err := ssh .NewSSHAgentAuth ("git" )
17
+ CheckIfError (err )
18
+
19
+ // Clone the given repository to the given directory
20
+ Info ("git clone %s " , url )
21
+
22
+ r , err := git .PlainClone (directory , false , & git.CloneOptions {
23
+ Auth : authMethod ,
24
+ URL : url ,
25
+ Progress : os .Stdout ,
26
+ })
27
+ CheckIfError (err )
28
+
29
+ // ... retrieving the branch being pointed by HEAD
30
+ ref , err := r .Head ()
31
+ CheckIfError (err )
32
+ // ... retrieving the commit object
33
+ commit , err := r .CommitObject (ref .Hash ())
34
+ CheckIfError (err )
35
+
36
+ fmt .Println (commit )
37
+ }
You can’t perform that action at this time.
0 commit comments