/** * AltGit - altgit * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Paolo Lulli * @copyright Paolo Lulli 2026 */ package gitrepo import "os/exec" // ReadFile returns the raw bytes of a file at the given branch and path by // running "git show :". Works for bare and non-bare repositories. func ReadFile(repoPath, branch, filePath string) ([]byte, error) { cmd := exec.Command("git", "-C", repoPath, "show", branch+":"+filePath) out, err := cmd.Output() if err != nil { return nil, err } return out, nil }