aboutsummaryrefslogtreecommitdiffstats
path: root/modules/repofiles
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-08-05 21:39:39 +0100
committerGitHub <noreply@github.com>2019-08-05 21:39:39 +0100
commit7ad67109d732bd560c8da0356aa555be467d786c (patch)
tree7c7a35761b01e2eec6a823f0caf40748c3b7f327 /modules/repofiles
parent1d8915ad5d9889c02dd98ab2c2f29aa8f5ee4dfa (diff)
downloadgitea-7ad67109d732bd560c8da0356aa555be467d786c.tar.gz
gitea-7ad67109d732bd560c8da0356aa555be467d786c.zip
Be more strict with git arguments (#7715)
* Be more strict with git arguments * fix-up commit test * use bindings for branch name
Diffstat (limited to 'modules/repofiles')
-rw-r--r--modules/repofiles/delete.go6
-rw-r--r--modules/repofiles/update.go7
2 files changed, 13 insertions, 0 deletions
diff --git a/modules/repofiles/delete.go b/modules/repofiles/delete.go
index 3d9b06b1c1..a8ab277b28 100644
--- a/modules/repofiles/delete.go
+++ b/modules/repofiles/delete.go
@@ -92,6 +92,12 @@ func DeleteRepoFile(repo *models.Repository, doer *models.User, opts *DeleteRepo
// Assigned LastCommitID in opts if it hasn't been set
if opts.LastCommitID == "" {
opts.LastCommitID = commit.ID.String()
+ } else {
+ lastCommitID, err := t.gitRepo.ConvertToSHA1(opts.LastCommitID)
+ if err != nil {
+ return nil, fmt.Errorf("DeleteRepoFile: Invalid last commit ID: %v", err)
+ }
+ opts.LastCommitID = lastCommitID.String()
}
// Get the files in the index
diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go
index 21df776060..26b5113f15 100644
--- a/modules/repofiles/update.go
+++ b/modules/repofiles/update.go
@@ -190,6 +190,13 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
// Assigned LastCommitID in opts if it hasn't been set
if opts.LastCommitID == "" {
opts.LastCommitID = commit.ID.String()
+ } else {
+ lastCommitID, err := t.gitRepo.ConvertToSHA1(opts.LastCommitID)
+ if err != nil {
+ return nil, fmt.Errorf("DeleteRepoFile: Invalid last commit ID: %v", err)
+ }
+ opts.LastCommitID = lastCommitID.String()
+
}
encoding := "UTF-8"