<commit_before>package commands

import (
	"os"
	"strings"
	"github.com/jingweno/gh/git"
	"github.com/jingweno/gh/utils"
)

var cmdPush = &Command{
	Run: push,
	Usage: "push REMOTE-1,REMOTE-2,...,REMOTE-N [REF]",
	Short: "Update remote refs along with associated objects",
	Long: `Push REF to each of REMOTE-1 through REMOTE-N by executing  mul-
tiple git push commands.`,
}

/**
 $ git push origin,staging,qa bert_timeout
 > git push origin bert_timeout
 > git push staging bert_timeout
 > git push qa bert_timeout
**/

func push (command *Command, args *Args) {
	if !args.IsParamsEmpty() {
		pushToEveryRemote(args)
	}
}

func pushToEveryRemote (args *Args) {
	remotes, ref := getRemotesRef(args)
	for _, i := range remotes {
		err := git.Spawn("push", i, ref)
		utils.Check(err)
	}

	os.Exit(0)
}

func getRemotesRef(args *Args) (remotes []string, ref string) {
	remotes = strings.Split(args.GetParam(0), ",")
	if args.ParamsSize() == 2 {
		ref = args.GetParam(1)
	} else {
		ref = ""
	}
	
	return
}<commit_msg>Rewrite because previous implementation was overwriting options<commit_after>package commands

import (
	"os"
	"strings"
	"github.com/jingweno/gh/utils"
)

var cmdPush = &Command{
	Run: push,
	Usage: "push REMOTE-1,REMOTE-2,...,REMOTE-N [REF]",
	Short: "Update remote refs along with associated objects",
	Long: `Push REF to each of REMOTE-1 through REMOTE-N by executing  mul-
tiple git push commands.`,
}

/**
 $ git push origin,staging,qa bert_timeout
 > git push origin bert_timeout
 > git push staging bert_timeout
 > git push qa bert_timeout
**/

func push (command *Command, args *Args) {
	if !args.IsParamsEmpty() {
		pushToEveryRemote(args)
	}
}

func pushToEveryRemote (args *Args) {
	remotes, idx := getRemotes(args)
	for _, i := range remotes {
		copyArgs := args
		copyArgs.ReplaceParam(idx, i)
		err := copyArgs.ToCmd().Exec()
		utils.Check(err)
	}

	os.Exit(0)
}

func getRemotes(args *Args) (remotes []string, idx int) {
	for a, i := range args.Params {
		if !strings.HasPrefix(i, "-") {
			remotes = strings.Split(i, ",")
			idx = a
			return
		}
	}

	return
}
{'fraction_non_alphanumeric': 0.1401243424198948, 'fraction_numerical': 0.0052606408417025345, 'mean_word_length': 3.9339622641509435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4285439', 'n_tokens_mistral': 825, 'n_tokens_neox': 774, 'n_words': 208}