Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit c9353b2

Browse files
committed
README and examples progress
1 parent b3adbed commit c9353b2

File tree

4 files changed

+48
-15
lines changed

4 files changed

+48
-15
lines changed

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# go-git [![GoDoc](https://godoc.org/gopkg.in/src-d/go-git.v4?status.svg)](https://godoc.org/gopkg.in/src-d/go-git.v4) [![Build Status](https://travis-ci.org/src-d/go-git.svg)](https://travis-ci.org/src-d/go-git) [![codecov.io](https://codecov.io/github/src-d/go-git/coverage.svg)](https://codecov.io/github/src-d/go-git) [![codebeat badge](https://codebeat.co/badges/b6cb2f73-9e54-483d-89f9-4b95a911f40c)](https://codebeat.co/projects/github-com-src-d-go-git)
22

3-
A low level and highly extensible git implementation in **pure Go**.
3+
A low level and highly extensible git implementation in **pure Go**.
44

55
*go-git* aims to reach the completeness of [libgit2](https://libgit2.github.com/) or [jgit](http://www.eclipse.org/jgit/), nowadays covers the **majority** of the plumbing **read operations** and **some** of the main **write operations**, but lacks the main porcelain operations such as merges.
66

@@ -12,7 +12,7 @@ The master branch represents the `v4` of the library, it is currently under acti
1212

1313
If you are looking for a production ready version, please take a look to the [`v3`](https://github.com/src-d/go-git/tree/v3) which is being used in production at [source{d}](http://sourced.tech) since August 2015 to analyze all GitHub public repositories (i.e. 16M repositories).
1414

15-
We recommend the use of `v4` to develop new projects since it includes much new functionality and provides a more *idiomatic git* API
15+
We recommend the use of `v4` to develop new projects since it includes much new functionality and provides a more *idiomatic git* API
1616

1717
Installation
1818
------------
@@ -29,7 +29,7 @@ Examples
2929

3030
Cloning a repository and printing the history of HEAD, just like `git log` does
3131

32-
> Please note that the functions `CheckIfError` and `Inf`o used in the examples are from the [examples package](https://github.com/src-d/go-git/blob/master/examples/common.go#L17) just to be used in the examples.
32+
> Please note that the functions `CheckIfError` and `Info` used in the examples are from the [examples package](https://github.com/src-d/go-git/blob/master/examples/common.go#L17) just to be used in the examples.
3333
3434

3535
```go
@@ -66,21 +66,20 @@ for _, c := range history {
6666

6767
Outputs:
6868
```
69-
commit 2275fa7d0c75d20103f90b0e1616937d5a9fc5e6
70-
Author: Máximo Cuadros <[email protected]>
71-
Date: 2015-10-23 00:44:33 +0200 +0200
69+
commit ded8054fd0c3994453e9c8aacaf48d118d42991e
70+
Author: Santiago M. Mola <[email protected]>
71+
Date: Sat Nov 12 21:18:41 2016 +0100
7272
73-
commit 35b585759cbf29f8ec428ef89da20705d59f99ec
74-
Author: Carlos Cobo <[email protected]>
75-
Date: 2015-05-20 15:21:37 +0200 +0200
73+
index: ReadFrom/WriteTo returns IndexReadError/IndexWriteError. (#9)
7674
77-
commit 7e3259c191a9de23d88b6077dcb1cd427e925432
78-
Author: Alberto Cortés <[email protected]>
79-
Date: 2016-01-21 03:29:57 +0100 +0100
75+
commit df707095626f384ce2dc1a83b30f9a21d69b9dfc
76+
Author: Santiago M. Mola <[email protected]>
77+
Date: Fri Nov 11 13:23:22 2016 +0100
8078
81-
commit 24b8ae50db91f3909b11304014564bffc6fdee79
82-
Author: Alberto Cortés <[email protected]>
83-
Date: 2015-12-11 17:57:10 +0100 +0100
79+
readwriter: fix bug when writing index. (#10)
80+
81+
When using ReadWriter on an existing siva file, absolute offset for
82+
index entries was not being calculated correctly.
8483
...
8584
```
8685

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Here you can find a list of annotated _go-git_ examples:
77
- [open](open/main.go) - Opening a existing repository cloned by _git_
88
- [clone](clone/main.go) - Cloning a repository
99
- [remotes](remotes/main.go) - Working with remotes: adding, removing, etc
10+
- [progress](progress/main.go) - Priting the progress information from the sideband
1011

1112
### Advanced
1213
- [custom_http](custom_http/main.go) - Replacing the HTTP client using a custom one

examples/common_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var args = map[string][]string{
1818
"showcase": []string{defaultURL},
1919
"custom_http": []string{defaultURL},
2020
"clone": []string{defaultURL, tempFolder()},
21+
"progress": []string{defaultURL, tempFolder()},
2122
"open": []string{filepath.Join(cloneRepository(defaultURL, tempFolder()), ".git")},
2223
}
2324

examples/progress/main.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
func main() {
11+
CheckArgs("<url>", "<directory>")
12+
url := os.Args[1]
13+
directory := os.Args[2]
14+
15+
r, err := git.NewFilesystemRepository(directory)
16+
CheckIfError(err)
17+
18+
// as git does, when you make a clone, pull or some other operations, the
19+
// server sends information via the sideband, this information can being
20+
// collected provinding a io.Writer to the repository
21+
r.Progress = os.Stdout
22+
23+
// Clone the given repository to the given directory
24+
Info("git clone %s %s", url, directory)
25+
26+
err = r.Clone(&git.CloneOptions{
27+
URL: url,
28+
Depth: 1,
29+
})
30+
31+
CheckIfError(err)
32+
}

0 commit comments

Comments
 (0)