UpdateVersionFile function

Added UpdateVersionFile to the repo/manifest_version package.
This updates the chromeos_version.sh file and pushes the change
to a specified remote.

BUG=chromium:980346
TEST=run_tests.sh

Change-Id: Ib4900aac418561303d22bddbcf69f5f71dad9264
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/infra/go/+/1701757
Commit-Queue: Jack Neus <jackneus@google.com>
Tested-by: Jack Neus <jackneus@google.com>
Reviewed-by: Evan Hernandez <evanhernandez@chromium.org>
diff --git a/internal/git/git.go b/internal/git/git.go
index f4a7ee4..be5e613 100644
--- a/internal/git/git.go
+++ b/internal/git/git.go
@@ -109,3 +109,35 @@
 	}
 	return ref
 }
+
+// CreateBranch creates a branch.
+func CreateBranch(gitRepo, branch string) error {
+	_, err := RunGit(gitRepo, []string{"checkout", "-B", branch, "HEAD"})
+	return err
+}
+
+// CommitAll adds all local changes and commits them.
+func CommitAll(gitRepo, commitMsg string) error {
+	if _, err := RunGit(gitRepo, []string{"add", "-A"}); err != nil {
+		return err
+	}
+	if _, err := RunGit(gitRepo, []string{"commit", "-m", commitMsg}); err != nil {
+		return err
+	}
+	return nil
+}
+
+// PushGitChanges stages and commits any local changes before pushing the commit
+// to the specified remote ref.
+func PushChanges(gitRepo, localRef, commitMsg string, dryRun bool, pushTo RemoteRef) error {
+	if err := CommitAll(gitRepo, commitMsg); err != nil {
+		return err
+	}
+	ref := fmt.Sprintf("%s:%s", localRef, pushTo.Ref)
+	cmd := []string{"push", pushTo.Remote, ref}
+	if dryRun {
+		cmd = append(cmd, "--dry-run")
+	}
+	_, err := RunGit(gitRepo, cmd)
+	return err
+}