diff options
author | a1012112796 <1012112796@qq.com> | 2021-03-01 20:14:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 14:14:17 +0200 |
commit | 6cf97df9fd6aba59104dba41a2eabd64542f68b9 (patch) | |
tree | b372ec58b6315df4e26a01b2d09acc2f6ca52d13 /modules/repofiles/temp_repo.go | |
parent | faf775c552ae18a9ca55050fedf86908d09dd3f6 (diff) | |
download | gitea-6cf97df9fd6aba59104dba41a2eabd64542f68b9.tar.gz gitea-6cf97df9fd6aba59104dba41a2eabd64542f68b9.zip |
remove duplicate define of CheckAttribute() (#14837)
Signed-off-by: a1012112796 <1012112796@qq.com>
Diffstat (limited to 'modules/repofiles/temp_repo.go')
-rw-r--r-- | modules/repofiles/temp_repo.go | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/modules/repofiles/temp_repo.go b/modules/repofiles/temp_repo.go index 99c62a16c6..820f5f2542 100644 --- a/modules/repofiles/temp_repo.go +++ b/modules/repofiles/temp_repo.go @@ -328,61 +328,6 @@ func (t *TemporaryUploadRepository) DiffIndex() (*gitdiff.Diff, error) { return diff, nil } -// CheckAttribute checks the given attribute of the provided files -func (t *TemporaryUploadRepository) CheckAttribute(attribute string, args ...string) (map[string]map[string]string, error) { - err := git.LoadGitVersion() - if err != nil { - log.Error("Error retrieving git version: %v", err) - return nil, err - } - - stdout := new(bytes.Buffer) - stderr := new(bytes.Buffer) - - cmdArgs := []string{"check-attr", "-z", attribute} - - // git check-attr --cached first appears in git 1.7.8 - if git.CheckGitVersionAtLeast("1.7.8") == nil { - cmdArgs = append(cmdArgs, "--cached") - } - cmdArgs = append(cmdArgs, "--") - - for _, arg := range args { - if arg != "" { - cmdArgs = append(cmdArgs, arg) - } - } - - if err := git.NewCommand(cmdArgs...).RunInDirPipeline(t.basePath, stdout, stderr); err != nil { - log.Error("Unable to check-attr in temporary repo: %s (%s) Error: %v\nStdout: %s\nStderr: %s", - t.repo.FullName(), t.basePath, err, stdout, stderr) - return nil, fmt.Errorf("Unable to check-attr in temporary repo: %s Error: %v\nStdout: %s\nStderr: %s", - t.repo.FullName(), err, stdout, stderr) - } - - fields := bytes.Split(stdout.Bytes(), []byte{'\000'}) - - if len(fields)%3 != 1 { - return nil, fmt.Errorf("Wrong number of fields in return from check-attr") - } - - var name2attribute2info = make(map[string]map[string]string) - - for i := 0; i < (len(fields) / 3); i++ { - filename := string(fields[3*i]) - attribute := string(fields[3*i+1]) - info := string(fields[3*i+2]) - attribute2info := name2attribute2info[filename] - if attribute2info == nil { - attribute2info = make(map[string]string) - } - attribute2info[attribute] = info - name2attribute2info[filename] = attribute2info - } - - return name2attribute2info, err -} - // GetBranchCommit Gets the commit object of the given branch func (t *TemporaryUploadRepository) GetBranchCommit(branch string) (*git.Commit, error) { if t.gitRepo == nil { |