Dear Gitlab users, due to maintenance reasons, Gitlab will not be available on Thursday 30.09.2021 from 5:00 pm to approximately 5:30 pm.

Commit 8d5a93b5 authored by Andreas Wagner's avatar Andreas Wagner
Browse files

Catch truncated trees. Just not supported for now.

parent 95bafd7b
......@@ -554,7 +554,7 @@ func PutFile(myDeposit *tei2zenodo.Deposit, conf *tei2zenodo.Config, c *gin.Cont
oldCommitSHA := myDeposit.CommitSHA
log.Tracef(" Commit to base the new commit on (from internal myDeposit object): %s", oldCommitSHA)
// 2. get old tree (=baseTree)
// 2. get old commit and its tree (=baseTree)
oldCommit, _, OCErr := client.Git.GetCommit(c, ownerName, repoName, oldCommitSHA)
if OCErr != nil {
log.Errorf("Problem getting old commit: %v ...", OCErr)
......@@ -566,6 +566,10 @@ func PutFile(myDeposit *tei2zenodo.Deposit, conf *tei2zenodo.Config, c *gin.Cont
log.Errorf("Problem getting old tree: %v ...", GTErr)
return "", tei2zenodo.NewError("errGHProcessing", fmt.Sprintf("problem getting old tree: %s", GTErr.Error()), 500, GTErr)
}
if *baseTree.Truncated {
log.Errorf("Old tree is too large and has been truncated. This is not supported yet", nil)
return "", tei2zenodo.NewError("errGHProcessing", fmt.Sprintf("old tree is too large and has been truncated. This is not supported yet"), 500, nil)
}
log.Tracef(" Tree object of the old commit: %v", *baseTree)
// 3. create and post new tree object (get new treeSHA)
......@@ -588,17 +592,18 @@ func PutFile(myDeposit *tei2zenodo.Deposit, conf *tei2zenodo.Config, c *gin.Cont
log.Tracef(" New tree object: %v", *newTree)
// 4. create and post new commit object (use old commit SHA as parent and new tree SHA; get new commit SHA)
commitAuthor := "tei2zenodo service"
commitAuthorEMail := "bla@foo.com"
var commitMessage string
if myDeposit.DoPublish {
commitMessage = conf.T2ZCommitMessage // "Zenodo DOI updated"
} else {
commitMessage = conf.T2ZCommitMessage + " (not published at zenodo yet)"
}
date := time.Now()
author := &github.CommitAuthor{Date: &date, Name: &commitAuthor, Email: &commitAuthorEMail}
commit := &github.Commit{Author: author, Message: &commitMessage, Tree: newTree, Parents: []*github.Commit{oldCommit}}
// commitAuthor := "tei2zenodo service"
// commitAuthorEMail := "bla@foo.com"
// date := time.Now()
// author := &github.CommitAuthor{Date: &date, Name: &commitAuthor, Email: &commitAuthorEMail}
// commit := &github.Commit{Author: author, Message: &commitMessage, Tree: newTree, Parents: []*github.Commit{oldCommit}}
commit := &github.Commit{Message: &commitMessage, Tree: newTree, Parents: []*github.Commit{oldCommit}}
newCommit, _, NCErr := client.Git.CreateCommit(c, ownerName, repoName, commit)
if NCErr != nil {
log.Errorf("error creating commit object: %v ...", NCErr)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment