| 1 |
package main |
| 2 |
|
| 3 |
import ( |
| 4 |
"os" |
| 5 |
|
| 6 |
"gopkg.in/src-d/go-git.v4" |
| 7 |
. "gopkg.in/src-d/go-git.v4/_examples" |
| 8 |
) |
| 9 |
|
| 10 |
// Example of how to show the progress when you do a basic clone operation. |
| 11 |
func main() { |
| 12 |
CheckArgs("<url>", "<directory>") |
| 13 |
url := os.Args[1] |
| 14 |
directory := os.Args[2] |
| 15 |
|
| 16 |
// Clone the given repository to the given directory |
| 17 |
Info("git clone %s %s", url, directory) |
| 18 |
|
| 19 |
_, err := git.PlainClone(directory, false, &git.CloneOptions{ |
| 20 |
URL: url, |
| 21 |
Depth: 1, |
| 22 |
|
| 23 |
// as git does, when you make a clone, pull or some other operations the |
| 24 |
// server sends information via the sideband, this information can being |
| 25 |
// collected provinding a io.Writer to the CloneOptions options |
| 26 |
Progress: os.Stdout, |
| 27 |
}) |
| 28 |
|
| 29 |
CheckIfError(err) |
| 30 |
} |