use user provided git author details
This commit is contained in:
3 files changed
+15
-3
No files matched your search
+4
-1
@@ -4,4 +4,7 @@ mongoURI=mongodb://localhost:27017
|
||||
databases=db_name_1, db_name_2, ...
|
||||
# Github repository ssh link
|
||||
github=git@github:Username/MongoDB_Backup_Repo.git
|
||||
|
||||
# Github Username for git commit --author
|
||||
github_author=Github_Username
|
||||
# Github email for git commit --author
|
||||
github_email=john_does@example.com
|
||||
@@ -9,6 +9,8 @@ A script to automatically handle the backing up of MongoDB databases and optiona
|
||||
mongoURI=mongodb://localhost:27017
|
||||
databases=db_name_1, db_name_2, ...
|
||||
github=git@github:Username/MongoDB_Backup_Repo.git
|
||||
github_author=Github_Username
|
||||
github_email=john_doe@example.com
|
||||
```
|
||||
**Note:** If you wish to backup more than one database at a time, be sure to seperate the database names with a comma and a space as follows "`, `".
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ const dtFormat string = "2006-01-02 15:04:05 Monday"
|
||||
|
||||
func Handle(err error) {
|
||||
if err != nil {
|
||||
LogToFile(err.Error())
|
||||
log.Panic(err.Error())
|
||||
}
|
||||
}
|
||||
@@ -42,8 +41,16 @@ func UploadToGithub(archiveDir string) {
|
||||
|
||||
now := time.Now()
|
||||
|
||||
var author string = os.Getenv("github_author")
|
||||
var email string = os.Getenv("github_email")
|
||||
|
||||
if author == "" || email == "" {
|
||||
LogToFile("ERROR - github link provided but no author or email, add to .env: github_author=<username> and github_email=<email>")
|
||||
log.Panic("Missing required .env: github_author, github_email")
|
||||
}
|
||||
|
||||
// Commit archive files
|
||||
cmd = exec.Command("git", "commit", "-m", fmt.Sprintf("'%s''", now.Format(dtFormat)))
|
||||
cmd = exec.Command("git", "commit", "-m", fmt.Sprintf("'%s''", now.Format(dtFormat)), fmt.Springf("--author=\"%s <%s>\"", author, email))
|
||||
cmd.Dir = archiveDir
|
||||
_, err = cmd.Output()
|
||||
Handle(err)
|
||||
|
||||
Reference in new issue
Block a user