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

worktree: checkout, create branch #487

Merged
merged 1 commit into from
Jul 19, 2017
Merged

worktree: checkout, create branch #487

merged 1 commit into from
Jul 19, 2017

Conversation

mcuadros
Copy link
Contributor

@mcuadros mcuadros commented Jul 17, 2017

This PR adds the options of create a branch when a Checkout is perform.
Fixes #481

options.go Outdated
@@ -194,20 +194,35 @@ type SubmoduleUpdateOptions struct {
RecurseSubmodules SubmoduleRescursivity
}

var (
ErrBranchHashExclusive = errors.New("Branch and Hash are mutual exclusive")
Copy link
Contributor

Choose a reason for hiding this comment

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

mutual exclusive -> mutually exclusive

options.go Outdated
// CheckoutOptions describes how a checkout 31operation should be performed.
type CheckoutOptions struct {
// Hash to be checked out, if used HEAD will in detached mode. Branch and
// Hash are mutual exclusive.
// Hash are mutual exclusive, if Create is not used.
Copy link
Contributor

Choose a reason for hiding this comment

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

mutual exclusive -> mutually exclusive

@@ -71,6 +77,29 @@ func (w *Worktree) Checkout(opts *CheckoutOptions) error {

return w.Reset(ro)
}
func (w *Worktree) createBranch(opts *CheckoutOptions) error {
_, err := w.r.Storer.Reference(opts.Branch)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the checking existence of and creation of the reference all delegates through w.r, does it make sense to push the API for creating and updating branches into Repository instead? Especially considering that the standard git branch tool allows the creation and management of branches within bare repositories (and bare go-git repositories have nil Worktrees)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, maybe make sense having Repository.CreateBranch let me thing about it.

@codecov
Copy link

codecov bot commented Jul 18, 2017

Codecov Report

Merging #487 into master will decrease coverage by 0.63%.
The diff coverage is 68%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #487      +/-   ##
==========================================
- Coverage   78.12%   77.49%   -0.64%     
==========================================
  Files         127      127              
  Lines        9313     9334      +21     
==========================================
- Hits         7276     7233      -43     
- Misses       1241     1317      +76     
+ Partials      796      784      -12
Impacted Files Coverage Δ
options.go 81.03% <100%> (+1.4%) ⬆️
worktree.go 65.87% <61.9%> (-0.08%) ⬇️
plumbing/transport/ssh/common.go 2.81% <0%> (-45.08%) ⬇️
plumbing/transport/ssh/auth_method.go 33.33% <0%> (-24.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bebcb4f...9afc472. Read the comment docs.

@mcuadros mcuadros merged commit 9775f82 into src-d:master Jul 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants