Make a temporary clone of the repository

andybalholm
Mar 11, 2023, 9:41 PM
KZ4XMKSPLDYKDWCDZXTIJXZPXUZPMGYSZAIIJTQQSYDZVWOZVI5AC

Dependencies

  • [2] RFMRCLJX Remove empty parentheses after author name
  • [3] RTQQLOCO Use real metadata, but no content yet
  • [4] Y7VFVY6E Initial dummy version

Change contents

  • edit in main.go at line 9
    [3.43]
    [2.0]
    "path/filepath"
  • replacement in main.go at line 14
    [3.45][3.45:116]()
    var repo = flag.String("repo", "", "path of the repository to export")
    [3.45]
    [3.73]
    var repo = flag.String("repo", ".", "path of the repository to export")
  • edit in main.go at line 35
    [3.126]
    [3.126]
    func printErrorAndExit(description string, err error) {
    fmt.Fprintf(os.Stderr, "%T\n", err)
    msg := err.Error()
    if err, ok := err.(*exec.ExitError); ok && len(err.Stderr) > 0 {
    msg = string(err.Stderr)
    }
    fmt.Fprintln(os.Stderr, description, msg)
    os.Exit(2)
    }
  • replacement in main.go at line 48
    [3.423][3.423:484](),[3.484][3.484:587](),[3.587][3.587:591]()
    if *repo != "" {
    err := os.Chdir(*repo)
    if err != nil {
    fmt.Fprintf(os.Stderr, "Error changing to directory of source repository: %v\n", err)
    os.Exit(2)
    }
    [3.423]
    [3.591]
    // Make a clone of the repository to work with, so that we don't mess up the original.
    tempDir, err := os.MkdirTemp("", "")
    if err != nil {
    printErrorAndExit("Error creating temporary directory:", err)
    }
    tempRepo := filepath.Join(tempDir, "repo")
    _, err = exec.Command("pijul", "clone", *repo, tempRepo).Output()
    if err != nil {
    printErrorAndExit("Error cloning the repository:", err)
    }
    if err := os.Chdir(tempRepo); err != nil {
    printErrorAndExit("Error changing to the clone of the repository:", err)
  • replacement in main.go at line 64
    [3.595][3.595:710]()
    logCmd := exec.Command("pijul", "log", "--description", "--output-format=json")
    logBytes, err := logCmd.Output()
    [3.595]
    [3.710]
    logBytes, err := exec.Command("pijul", "log", "--description", "--output-format=json").Output()
  • replacement in main.go at line 66
    [3.727][3.727:790](),[3.790][3.790:803]()
    fmt.Fprintf(os.Stderr, "Error running pijul log: %v\n", err)
    os.Exit(2)
    [3.727]
    [3.803]
    printErrorAndExit("Error running pijul log:", err)
  • replacement in main.go at line 72
    [3.888][3.888:971]()
    fmt.Fprintf(os.Stderr, "Error parsing pijul log output: %v\n", err)
    os.Exit(2)
    [3.888]
    [3.971]
    printErrorAndExit("Error parsing pijul log output:", err)
  • edit in main.go at line 91
    [2.89]
    [2.89]
    if !strings.Contains(author, "<") {
    author = "<" + author + ">"
    }
  • edit in main.go at line 108
    [3.1677]
    [3.1677]
    }
    if err := os.RemoveAll(tempDir); err != nil {
    printErrorAndExit("Error removing temporary directory:", err)