Commit e424f4b1 authored by Andreas Wagner's avatar Andreas Wagner
Browse files

Improve git commit message and code comments.

parent c94b4724
......@@ -319,7 +319,7 @@ type FileInfo struct {
// 4. upload a file to github
// ProcessHook processes a Webhook's payload
// it returns a (boolean) doPublish value, a map of filenames/urls with all concerned files, and an error value
// Returns a (boolean) doPublish value, a map of filenames/urls with all concerned files, and an error value
func ProcessHook(hookType string, r io.ReadSeeker, conf *tei2zenodo.Config) (map[string]FileInfo, *tei2zenodo.Error) {
switch hookType {
......@@ -360,7 +360,7 @@ func ProcessHook(hookType string, r io.ReadSeeker, conf *tei2zenodo.Config) (map
log.Debugf(" commit %s (%s) ...", commitSHA, c.Message)
// Filtering based on commit messages
if c.Message == conf.T2ZCommitMessage || c.Message == conf.T2ZCommitMessage+" (not published at zenodo yet)" {
if strings.HasPrefix(c.Message, conf.T2ZCommitMessage) {
log.Debugf(" Commit %s was created by this service, ignore (avoid recursive calls)", commitSHA)
continue
}
......@@ -498,7 +498,7 @@ func retrieveFiles(commitsURL string, commitSHA string, conf *tei2zenodo.Config)
}
// DownloadFile takes a Deposit downloads the file from githubRawURL
// it returns a ReadSeeker and an error value
// Returns a ReadSeeker and an error value
func DownloadFile(myDeposit *tei2zenodo.Deposit, conf *tei2zenodo.Config) (r io.ReadSeeker, err *tei2zenodo.Error) {
// Compile GET request
......@@ -532,7 +532,7 @@ func DownloadFile(myDeposit *tei2zenodo.Deposit, conf *tei2zenodo.Config) (r io.
}
// PutFile uploads a file to the github repository and commits
// it returns the commit sha and an error value
// Returns the commit sha and an error value
func PutFile(myDeposit *tei2zenodo.Deposit, conf *tei2zenodo.Config, c *gin.Context) (string, error) {
githubConf := conf.Git
......@@ -600,9 +600,9 @@ func PutFile(myDeposit *tei2zenodo.Deposit, conf *tei2zenodo.Config, c *gin.Cont
// 4. create and post new commit object (use old commit SHA as parent and new tree SHA; get new commit SHA)
var commitMessage string
if myDeposit.DoPublish {
commitMessage = conf.T2ZCommitMessage // "Zenodo DOI updated"
commitMessage = conf.T2ZCommitMessage + " in " + myDeposit.Filename + "." // "Zenodo DOI updated"
} else {
commitMessage = conf.T2ZCommitMessage + " (not published at zenodo yet)"
commitMessage = conf.T2ZCommitMessage + " in " + myDeposit.Filename + " (not published at zenodo yet)."
}
// commitAuthor := "tei2zenodo service"
// commitAuthorEMail := "bla@foo.com"
......
......@@ -16,8 +16,8 @@ import (
"gitlab.gwdg.de/rg-mpg-de/tei2zenodo"
)
// GetFilename extracts what can serve as filename. Like /TEI/@xml:id
// it returns a string to serve as filename and an error value
// GetFilename extracts what can serve as filename (e.g. /TEI/@xml:id)
// Returns a string to serve as filename and an error value
func GetFilename(r io.Reader) (string, error) {
// Parse document (in r) wih antchfx/xmlquery...
doc, err := xmlquery.Parse(r)
......@@ -280,7 +280,7 @@ func ParseTEI(r io.Reader, md *tei2zenodo.ZMetadata, c *tei2zenodo.Config) (stri
}
// MixinDOI adds a DOI idno element to the document
// it returns the string serialization of the new document and an error value
// Returns the string serialization of the new document and an error value
func MixinDOI(r io.Reader, doi string, c *tei2zenodo.Config) (string, error) {
// Parse document (in r)...
......
// Package tei2zenodo parses TEI files for metadata and published them on zenodo.
// Files can be fed via REST POST or by calling a webhook that will retrieve the file(s).
// This file - tei2zenodo.go - mainly defines the data types used in the application
package tei2zenodo
// Config is the struct of the application's general configuration.
......
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