Use real metadata, but no content yet

andybalholm
Mar 11, 2023, 6:19 PM
RTQQLOCOBMMY5RQ6QI7TYKILLSSW5YNVPA33NL4MHM27QXMOCKPQC

Dependencies

Change contents

  • edit in main.go at line 4
    [3.56]
    [3.56]
    "encoding/json"
    "flag"
  • edit in main.go at line 7
    [3.63]
    [3.63]
    "os"
    "os/exec"
  • edit in main.go at line 11
    [3.73]
    [3.73]
    var repo = flag.String("repo", "", "path of the repository to export")
  • edit in main.go at line 16
    [2.96]
    [2.96]
    }
    type change struct {
    Hash string `json:"hash"`
    Authors []string `json:"authors"`
    Timestamp time.Time `json:"timestamp"`
    Message string `json:"message"`
    Description string `json:"description"`
    }
    var marks = 0
    func nextMark() int {
    marks++
    return marks
  • replacement in main.go at line 34
    [3.140][3.140:205](),[3.205][2.99:181](),[2.181][3.294:384](),[3.294][3.294:384]()
    fmt.Println("commit refs/heads/master")
    fmt.Println("mark :1")
    fmt.Println("committer Andy Balholm <andy@balholm.com>", formatTime(time.Now()))
    fmt.Println("data <<END")
    fmt.Println("Test commit")
    fmt.Println("END")
    fmt.Println()
    [3.140]
    [3.384]
    flag.Parse()
    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)
    }
    }
    logCmd := exec.Command("pijul", "log", "--description", "--output-format=json")
    logBytes, err := logCmd.Output()
    if err != nil {
    fmt.Fprintf(os.Stderr, "Error running pijul log: %v\n", err)
    os.Exit(2)
    }
    var changes []change
    err = json.Unmarshal(logBytes, &changes)
    if err != nil {
    fmt.Fprintf(os.Stderr, "Error parsing pijul log output: %v\n", err)
    os.Exit(2)
    }
    previousCommitMark := 0
    for changeIndex := len(changes) - 1; changeIndex >= 0; changeIndex-- {
    c := changes[changeIndex]
    if len(c.Authors) == 0 && changeIndex == len(changes)-1 {
    // Skip the original, empty change.
    continue
    }
    commitMark := nextMark()
    fmt.Println("commit refs/heads/master")
    fmt.Printf("mark :%d\n", commitMark)
    fmt.Println("committer", c.Authors[0], formatTime(c.Timestamp))
    message := c.Message
    if c.Description != "" {
    message += "\n\n" + c.Description
    }
    fmt.Println("data", len(message))
    fmt.Println(message)
    if previousCommitMark != 0 {
    fmt.Printf("from :%d\n", previousCommitMark)
    }
    fmt.Println()
    previousCommitMark = commitMark
    }