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

_examples: improve documentation (fix #238) #293

Merged
merged 2 commits into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions _examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ Here you can find a list of annotated _go-git_ examples:
- [showcase](showcase/main.go) - A small showcase of the capabilities of _go-git_
- [open](open/main.go) - Opening a existing repository cloned by _git_
- [clone](clone/main.go) - Cloning a repository
- [log](log/main.go) - Emulate `git log` command output iterating all the commit history from HEAD reference
- [remotes](remotes/main.go) - Working with remotes: adding, removing, etc
- [progress](progress/main.go) - Priting the progress information from the sideband

- [progress](progress/main.go) - Printing the progress information from the sideband
- [push](push/main.go) - Push repository to default remote (origin)
### Advanced
- [custom_http](custom_http/main.go) - Replacing the HTTP client using a custom one
- [storage](storage/README.md) - Implementing a custom storage system
1 change: 1 addition & 0 deletions _examples/clone/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
. "srcd.works/go-git.v4/_examples"
)

// Basic example of how to clone a repository using clone options.
func main() {
CheckArgs("<url>", "<directory>")
url := os.Args[1]
Expand Down
5 changes: 5 additions & 0 deletions _examples/log/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
"srcd.works/go-git.v4/storage/memory"
)

// Example of how to:
// - Clone a repository into memory
// - Get the HEAD reference
// - Using the HEAD reference, obtain the commit this reference is pointing to
// - Using the commit, obtain its history and print it
func main() {
// Clones the given repository, creating the remote, the local branches
// and fetching the objects, everything in memory:
Expand Down
1 change: 1 addition & 0 deletions _examples/open/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
. "srcd.works/go-git.v4/_examples"
)

// Open an existing repository in a specific folder.
func main() {
CheckArgs("<path>")
path := os.Args[1]
Expand Down
1 change: 1 addition & 0 deletions _examples/progress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
. "srcd.works/go-git.v4/_examples"
)

// Example of how to show the progress when you do a basic clone operation.
func main() {
CheckArgs("<url>", "<directory>")
url := os.Args[1]
Expand Down
3 changes: 3 additions & 0 deletions _examples/push/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
. "srcd.works/go-git.v4/_examples"
)

// Example of how to open a repository in a specific path, and do a push to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do a push -> push

// his default remote (origin).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

his -> its

func main() {
CheckArgs("<repository-path>")
path := os.Args[1]
Expand All @@ -15,6 +17,7 @@ func main() {
CheckIfError(err)

Info("git push")
// push using default push options
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

push options -> options

err = r.Push(&git.PushOptions{})
CheckIfError(err)
}
7 changes: 7 additions & 0 deletions _examples/remotes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import (
"srcd.works/go-git.v4/storage/memory"
)

// Example of how to:
// - Create a new repository into memory
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repository into memoty -> in-memory repository

// - Create a new remote called "example"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

called -> named

// - List remotes and print them
// - Pull using the new remote "example"
// - Iterate again the references, but only showing hash references, not simbolic ones
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iterate again the references -> iterate the refererences again
simbolic -> symbolic

// - Remove remote "example"
func main() {
// Create a new repository
Info("git init")
Expand Down
8 changes: 8 additions & 0 deletions _examples/showcase/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ import (
. "srcd.works/go-git.v4/_examples"
)

// Example of an specific use case:
// - Clone a repository in a specific path
// - Get the HEAD reference
// - Using the HEAD reference, obtain the commit this reference is pointing to
// - Print the commit content
// - Using the commit, iterate all its files and print them
// - Print all the commit history with commit messages, short hash and the
// first line of the commit message
func main() {
CheckArgs("<url> <path>")
url := os.Args[1]
Expand Down