|
|
@@ -435,6 +435,11 @@ type UploadRepoFileOptions struct {
|
|
|
Files []string // In UUID format
|
|
|
}
|
|
|
|
|
|
+// isRepositoryGitPath returns true if given path is or resides inside ".git" path of the repository.
|
|
|
+func isRepositoryGitPath(path string) bool {
|
|
|
+ return strings.HasSuffix(path, ".git") || strings.Contains(path, ".git"+string(os.PathSeparator))
|
|
|
+}
|
|
|
+
|
|
|
// UploadRepoFiles uploads files to a repository
|
|
|
func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) (err error) {
|
|
|
if len(opts.Files) == 0 {
|
|
|
@@ -473,7 +478,7 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
|
|
|
}
|
|
|
|
|
|
// Prevent copying files into .git directory
|
|
|
- if strings.HasPrefix(upload.Name, ".git/") {
|
|
|
+ if isRepositoryGitPath(upload.Name) {
|
|
|
continue
|
|
|
}
|
|
|
|