Skip to content

Commit

Permalink
💡 Refer to upstream directly when creating new branch (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
re-fort authored Nov 11, 2017
1 parent 2a472ff commit 8711a9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function setupHeadFeeder() {
}

repo.fetchAllRemotes()
repo.updateLocal()
repo.updateDefaultBranch()
repo.createNewBranch(shortHash)

if (repo.hasConflicts('cherry-pick', hash)) {
Expand Down
17 changes: 11 additions & 6 deletions lib/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ class Repository {
Git.exec(`remote add ${this.remote.head.name} ${this.remote.head.url}`)
Git.exec(`config user.name "${this.user.name}"`)
Git.exec(`config user.email "${this.user.email}"`)
this.fetchUpstream()
if (this.remote.origin.defaultBranch === this.remote.upstream.defaultBranch) {
this.createNewBranch('tmp')
Git.exec(`branch -D ${this.remote.origin.defaultBranch}`)
}
this.createNewBranch(`${this.remote.upstream.defaultBranch} ${this.remote.upstream.name}/${this.remote.upstream.defaultBranch}`)
}
this.resetChanges()
this.checkputDefaultBranch()
this.checkoutDefaultBranch()
Git.exec('branch | grep -v "*" | xargs git branch -D')
}

Expand All @@ -29,7 +35,8 @@ class Repository {
this.fetchHead()
}

updateLocal() {
updateDefaultBranch() {
this.checkoutDefaultBranch()
this.mergeUpstream()
}

Expand All @@ -38,17 +45,15 @@ class Repository {
}

mergeUpstream() {
this.checkputDefaultBranch()
Git.merge(`${this.remote.upstream.name}/${this.remote.upstream.defaultBranch}`)
this.updateRemote(this.remote.origin.defaultBranch)
}

fetchHead() {
Git.fetch(this.remote.head.name, this.remote.head.defaultBranch)
}

checkputDefaultBranch() {
Git.checkout(this.remote.origin.defaultBranch)
checkoutDefaultBranch() {
Git.checkout(this.remote.upstream.defaultBranch)
}

updateRemote(branchName) {
Expand Down

0 comments on commit 8711a9b

Please sign in to comment.