repo.go 587 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package git
  5. import (
  6. "path/filepath"
  7. )
  8. // Repository represents a Git repository.
  9. type Repository struct {
  10. Path string
  11. commitCache map[sha1]*Commit
  12. tagCache map[sha1]*Tag
  13. }
  14. // OpenRepository opens the repository at the given path.
  15. func OpenRepository(repoPath string) (*Repository, error) {
  16. repoPath, err := filepath.Abs(repoPath)
  17. if err != nil {
  18. return nil, err
  19. }
  20. return &Repository{Path: repoPath}, nil
  21. }