// tryMerge attempts to merge a pull request locally
// The purpose of merging locally is that Github's  Mergable status s insufficient when a .gitatributes file
// is present. Because Github does not support custom merge drivers, e.g. `merge=union` from .gitattributes, merging
// using a git client that does support custom merge drivers is the only way to tell whether a branch is truly mergable.
tryMerge attempts to merge a pull request locally
The purpose of merging locally is that Github's  Mergable status s insufficient when a .gitatributes file
is present. Because Github does not support custom merge drivers, e.g. `merge=union` from .gitattributes, merging
using a git client that does support custom merge drivers is the only way to tell whether a branch is truly mergable.
// tryMerge attempts to merge a pull request locally // The purpose of merging locally is that Github ' s Mergable status s insufficient when a . gitatributes file // is present . Because Github does not support custom merge drivers e . g . ` merge = union ` from . gitattributes merging // using a git client that does support custom merge drivers is the only way to tell whether a branch is truly mergable .
func tryMerge(pr GithubPullRequest) (success bool) {
	g := services.git()
	baseRef := fmt.Sprintf("origin/%s", string(pr.BaseRefName))
	mergeRef := fmt.Sprintf("origin/%s", string(pr.HeadRefName))
	err := g.Checkout(baseRef)
	if err != nil {
		log.Printf("Error checking out base ref: %v", err)
		return
	}
	origBranchRef := g.CurrentRefName()
	log.Printf("trying to merge '%s' into '%s'", mergeRef, baseRef)
	err = g.Merge(mergeRef)
	if err != nil {
		log.Printf("Error trying to merge: %v", err)
		return
	}
	err = g.Reset(origBranchRef, "--hard")
	if err != nil {
		log.Printf("unable to reset head: %v", err)
		return
	}
	success = true
	return
}
func tryMerge ( pr GithubPullRequest ) ( success bool ) { g := services . git ( ) baseRef := fmt . Sprintf ( " " , string ( pr . BaseRefName ) ) mergeRef := fmt . Sprintf ( " " , string ( pr . HeadRefName ) ) err := g . Checkout ( baseRef ) if err != nil { log . Printf ( " " , err ) return } origBranchRef := g . CurrentRefName ( ) log . Printf ( " " , mergeRef , baseRef ) err = g . Merge ( mergeRef ) if err != nil { log . Printf ( " " , err ) return } err = g . Reset ( origBranchRef , " " ) if err != nil { log . Printf ( " " , err ) return } success = true return }
tryMerge attempts to merge a pull request locally
The purpose of merging locally is that Github's  Mergable status s insufficient when a .gitatributes file
is present.
tryMerge attempts to merge a pull request locally The purpose of merging locally is that Github ' s Mergable status s insufficient when a . gitatributes file is present .
//reset HEAD back to the HEAD prior to merging