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

config: adds branches to config for tracking branches against remotes… #803

Merged
merged 1 commit into from
Apr 11, 2018

Conversation

TheHipbot
Copy link
Contributor

Cloning against a branch will also track that branch against the remote. Allows the ability to create and modify branch tracking in git config.

  • Adds Branches to Config
  • Updates Repository.clone to include tracking against branch when clone is against a remote branch
  • Updates Repository.clone to track against master if no Reference is specified in CloneOptions
  • Adds Repository.CreateBranch to create new branch tracking on repository
  • Adds Repository.Branch to lookup branch tracking on repository
  • Adds Repository.DeleteBranch to delete branch tracking on repository
    …, updates clone to track when cloning a branch. Fixes Setup tracking for default branch when cloned. #313

Signed-off-by: Jeremy Chambers [email protected]

Copy link
Contributor

@mcuadros mcuadros left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, this was a pending feature for a long time, so is a very welcome PR.

I just request small changes.

config/branch.go Outdated
// Remote name of remote to track
Remote string
// Merge is the local refspec for the branch
Merge string
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 only value accepted in Merge is a branch the type should be a ReferenceName.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the quick feedback, I'll update the PR as soon as I can

config/branch.go Outdated
return errBranchEmptyName
}

if b.Merge != "" && !strings.HasPrefix(b.Merge, "refs/heads/") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Check this using ReferenceName.IsBranch

config/config.go Outdated
// Branches list of branches, the key is the branch name and should
// equal Branch.Name
Branches map[string]*Branch

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this extra line and also the 58.

@@ -87,19 +92,31 @@ func (c *Config) Validate() error {
}
}

for name, b := range c.Branches {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not covered by tests.

config/branch.go Outdated
// Branch contains information on the
// local branches and which remote to track
type Branch struct {
// Name name of branch
Copy link

Choose a reason for hiding this comment

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

No need to repeat the word name.

…, updates clone to track when cloning a branch. Fixes src-d#313

Signed-off-by: Jeremy Chambers <[email protected]>
@TheHipbot TheHipbot force-pushed the branch-tracking-on-clone branch from aabcd10 to 02335b1 Compare April 11, 2018 00:43
@mcuadros mcuadros merged commit 0db54e8 into src-d:master Apr 11, 2018
@TheHipbot TheHipbot deleted the branch-tracking-on-clone branch April 11, 2018 14:44
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.

3 participants