Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Commit

Permalink
Minor typo fixes and docs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
scorphus committed Sep 1, 2014
1 parent f0bbf56 commit dbb08dd
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 37 deletions.
12 changes: 6 additions & 6 deletions api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func SetupRouter() *pat.Router {
router.Get("/repository/{name:[^/]*/?[^/]+}/tags", http.HandlerFunc(getTags))
router.Get("/repository/{name:[^/]*/?[^/]+}/diff/commits", http.HandlerFunc(getDiff))
router.Post("/repository/{name:[^/]*/?[^/]+}/commit", http.HandlerFunc(commit))
router.Get("/repository/{name:[^/]*/?[^/]+}/logs", http.HandlerFunc(getLog))
router.Get("/repository/{name:[^/]*/?[^/]+}/logs", http.HandlerFunc(getLogs))
router.Post("/repository/grant", http.HandlerFunc(grantAccess))
router.Post("/repository", http.HandlerFunc(newRepository))
router.Get("/repository/{name:[^/]*/?[^/]+}", http.HandlerFunc(getRepository))
Expand Down Expand Up @@ -508,25 +508,25 @@ func commit(w http.ResponseWriter, r *http.Request) {
w.Write(b)
}

func getLog(w http.ResponseWriter, r *http.Request) {
func getLogs(w http.ResponseWriter, r *http.Request) {
repo := r.URL.Query().Get(":name")
ref := r.URL.Query().Get("ref")
path := r.URL.Query().Get("path")
total, err := strconv.Atoi(r.URL.Query().Get("total"))
if err != nil {
err := fmt.Errorf("Error when trying to obtain log for ref %s of repository %s (%s).", ref, repo, err)
err := fmt.Errorf("Error when trying to obtain logs for ref %s of repository %s (%s).", ref, repo, err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
logs, err := repository.GetLog(repo, ref, total, path)
logs, err := repository.GetLogs(repo, ref, total, path)
if err != nil {
err := fmt.Errorf("Error when trying to obtain log for ref %s of repository %s (%s).", ref, repo, err)
err := fmt.Errorf("Error when trying to obtain logs for ref %s of repository %s (%s).", ref, repo, err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
b, err := json.Marshal(logs)
if err != nil {
err := fmt.Errorf("Error when trying to obtain log for ref %s of repository %s (%s).", ref, repo, err)
err := fmt.Errorf("Error when trying to obtain logs for ref %s of repository %s (%s).", ref, repo, err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
Expand Down
10 changes: 5 additions & 5 deletions api/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (s *S) TestGetRepositoryWithNamespace(c *gocheck.C) {
}

func (s *S) TestGetRepositoryDoesNotExist(c *gocheck.C) {
recorder, request := get("/repository/doesnotexists", nil, c)
recorder, request := get("/repository/doesnotexist", nil, c)
s.router.ServeHTTP(recorder, request)
c.Assert(recorder.Code, gocheck.Equals, 500)
}
Expand Down Expand Up @@ -623,7 +623,7 @@ func (s *S) TestAddInvalidOldFormatHook(c *gocheck.C) {
c.Assert(recorder.Code, gocheck.Equals, 400)
}

func (s *S) TestAddKeyShouldReturnErrorWhenUserDoesNotExists(c *gocheck.C) {
func (s *S) TestAddKeyShouldReturnErrorWhenUserDoesNotExist(c *gocheck.C) {
b := strings.NewReader(`{"key": "a public key"}`)
recorder, request := post("/user/Frodo/key", b, c)
s.router.ServeHTTP(recorder, request)
Expand Down Expand Up @@ -872,7 +872,7 @@ func (s *S) TestRemoveRepositoryShouldReturn400OnFailure(c *gocheck.C) {
c.Assert(recorder.Code, gocheck.Equals, 400)
}

func (s *S) TestRemoveRepositoryShouldReturnErrorMsgWhenRepoDoesNotExists(c *gocheck.C) {
func (s *S) TestRemoveRepositoryShouldReturnErrorMsgWhenRepoDoesNotExist(c *gocheck.C) {
url := "/repository/foo"
request, err := http.NewRequest("DELETE", url, nil)
c.Assert(err, gocheck.IsNil)
Expand Down Expand Up @@ -1509,7 +1509,7 @@ func (s *S) TestPostNewCommitWithEmptyBranch(c *gocheck.C) {
c.Assert(recorder.Code, gocheck.Equals, http.StatusBadRequest)
}

func (s *S) TestLog(c *gocheck.C) {
func (s *S) TestLogs(c *gocheck.C) {
url := "/repository/repo/logs?ref=HEAD&total=1"
objects := repository.GitHistory{}
parent := make([]string, 2)
Expand Down Expand Up @@ -1551,7 +1551,7 @@ func (s *S) TestLog(c *gocheck.C) {
c.Assert(obj.Commits[0], gocheck.DeepEquals, commits[0])
}

func (s *S) TestLogWithPath(c *gocheck.C) {
func (s *S) TestLogsWithPath(c *gocheck.C) {
url := "/repository/repo/logs?ref=HEAD&total=1&path=README.txt"
objects := repository.GitHistory{}
parent := make([]string, 2)
Expand Down
2 changes: 1 addition & 1 deletion api/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *S) TestGetUserOr404(c *gocheck.C) {
c.Assert(rUser.Name, gocheck.Equals, "umi")
}

func (s *S) TestGetUserOr404ShouldReturn404WhenUserDoesntExists(c *gocheck.C) {
func (s *S) TestGetUserOr404ShouldReturn404WhenUserDoesntExist(c *gocheck.C) {
_, e := getUserOr404("umi")
expected := "User umi not found"
got := e.Error()
Expand Down
6 changes: 3 additions & 3 deletions bin/gandalf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (s *S) TestRequestedRepositoryShouldReturnErrorWhenThereIsNoCommandPassedTo
c.Assert(err, gocheck.ErrorMatches, "^You've tried to execute some weird command, I'm deliberately denying you to do that, get over it.$")
}

func (s *S) TestRequestedRepositoryShouldReturnFormatedErrorWhenRepositoryDoesNotExists(c *gocheck.C) {
func (s *S) TestRequestedRepositoryShouldReturnFormatedErrorWhenRepositoryDoesNotExist(c *gocheck.C) {
os.Setenv("SSH_ORIGINAL_COMMAND", "git-receive-pack 'inexistent-repo.git'")
defer os.Setenv("SSH_ORIGINAL_COMMAND", "")
_, err := requestedRepository()
Expand Down Expand Up @@ -248,7 +248,7 @@ func (s *S) TestExecuteActionShouldExecuteGitReceivePackWhenUserHasWritePermissi
c.Assert(stdout.String(), gocheck.Equals, expected)
}

func (s *S) TestExecuteActionShouldNotCallSSH_ORIGINAL_COMMANDWhenUserDoesNotExists(c *gocheck.C) {
func (s *S) TestExecuteActionShouldNotCallSSH_ORIGINAL_COMMANDWhenUserDoesNotExist(c *gocheck.C) {
dir, err := commandmocker.Add("git-receive-pack", "$*")
c.Check(err, gocheck.IsNil)
defer commandmocker.Remove(dir)
Expand All @@ -264,7 +264,7 @@ func (s *S) TestExecuteActionShouldNotCallSSH_ORIGINAL_COMMANDWhenUserDoesNotExi
c.Assert(commandmocker.Ran(dir), gocheck.Equals, false)
}

func (s *S) TestExecuteActionShouldNotCallSSH_ORIGINAL_COMMANDWhenRepositoryDoesNotExists(c *gocheck.C) {
func (s *S) TestExecuteActionShouldNotCallSSH_ORIGINAL_COMMANDWhenRepositoryDoesNotExist(c *gocheck.C) {
dir, err := commandmocker.Add("git-receive-pack", "$*")
c.Check(err, gocheck.IsNil)
defer commandmocker.Remove(dir)
Expand Down
10 changes: 5 additions & 5 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ Example URLs (http://gandalf-server omitted for clarity)::
$ curl /repository/myrepository/archive?ref=master&format=tar.gz # gets master and tar.gz format
$ curl /repository/myrepository/archive?ref=0.1.0&format=zip # gets 0.1.0 tag and zip format

Get branch
-----------
Get branches
------------

Returns a list of all the branches of the specified `repository`.

Expand Down Expand Up @@ -207,8 +207,8 @@ Example URL (http://gandalf-server omitted for clarity)::

$ curl /repository/myrepository/branches # gets list of branches

Get tag
-------
Get tags
--------

Returns a list of all the tags of the specified `repository`.

Expand Down Expand Up @@ -341,7 +341,7 @@ Logs
Returns a list of all commits into `repository`.

* Method: GET
* URI: /repository/`:name`/log?ref=:ref&total=:total
* URI: /repository/`:name`/logs?ref=:ref&total=:total
* Format: JSON

Where:
Expand Down
2 changes: 1 addition & 1 deletion repository/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func (r *MockContentRetriever) CommitZip(repo string, z *multipart.FileHeader, c
return &r.Ref, nil
}

func (r *MockContentRetriever) GetLog(repo, hash string, total int, path string) (*GitHistory, error) {
func (r *MockContentRetriever) GetLogs(repo, hash string, total int, path string) (*GitHistory, error) {
if r.LookPathError != nil {
return nil, r.LookPathError
}
Expand Down
10 changes: 5 additions & 5 deletions repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (r *Repository) isValid() (bool, error) {
}

// GrantAccess gives full or read-only permission for users in all specified repositories.
// If any of the repositories/users do not exists, GrantAccess just skips it.
// If any of the repositories/users does not exist, GrantAccess just skips it.
func GrantAccess(rNames, uNames []string, readOnly bool) error {
conn, err := db.Conn()
if err != nil {
Expand Down Expand Up @@ -345,7 +345,7 @@ type ContentRetriever interface {
Commit(cloneDir, message string, author GitUser) error
Push(cloneDir, branch string) error
CommitZip(repo string, z *multipart.FileHeader, c GitCommit) (*Ref, error)
GetLog(repo, hash string, total int, path string) (*GitHistory, error)
GetLogs(repo, hash string, total int, path string) (*GitHistory, error)
}

var Retriever ContentRetriever
Expand Down Expand Up @@ -718,7 +718,7 @@ func (*GitContentRetriever) CommitZip(repo string, z *multipart.FileHeader, c Gi
return nil, fmt.Errorf("Error when trying to commit zip to repository %s, could not check branch: %s", repo, err)
}

func (*GitContentRetriever) GetLog(repo, hash string, total int, path string) (*GitHistory, error) {
func (*GitContentRetriever) GetLogs(repo, hash string, total int, path string) (*GitHistory, error) {
if total < 1 {
total = 1
}
Expand Down Expand Up @@ -874,6 +874,6 @@ func CommitZip(repo string, z *multipart.FileHeader, c GitCommit) (*Ref, error)
return retriever().CommitZip(repo, z, c)
}

func GetLog(repo, hash string, total int, path string) (*GitHistory, error) {
return retriever().GetLog(repo, hash, total, path)
func GetLogs(repo, hash string, total int, path string) (*GitHistory, error) {
return retriever().GetLogs(repo, hash, total, path)
}
15 changes: 7 additions & 8 deletions repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func (s *S) TestRemoveShouldRemoveRepositoryFromDatabase(c *gocheck.C) {
c.Assert(err, gocheck.ErrorMatches, "^not found$")
}

func (s *S) TestRemoveShouldReturnMeaningfulErrorWhenRepositoryDoesNotExistsInDatabase(c *gocheck.C) {
func (s *S) TestRemoveShouldReturnMeaningfulErrorWhenRepositoryDoesNotExistInDatabase(c *gocheck.C) {
rfs := &fstesting.RecordingFs{FileContent: "foo"}
fs.Fsystem = rfs
defer func() { fs.Fsystem = nil }()
Expand Down Expand Up @@ -939,7 +939,6 @@ func (s *S) TestGetArchiveIntegrationWhenZip(c *gocheck.C) {
zipReader, err := zip.NewReader(reader, int64(len(zipContents)))
c.Assert(err, gocheck.IsNil)
for _, f := range zipReader.File {
//fmt.Printf("Contents of %s:\n", f.Name)
rc, err := f.Open()
c.Assert(err, gocheck.IsNil)
defer rc.Close()
Expand Down Expand Up @@ -1948,7 +1947,7 @@ func (s *S) TestCommitZipIntegrationWhenFileEmpty(c *gocheck.C) {
c.Assert(err.Error(), gocheck.Equals, expectedErr)
}

func (s *S) TestGetLog(c *gocheck.C) {
func (s *S) TestGetLogs(c *gocheck.C) {
oldBare := bare
bare = "/tmp"
repo := "gandalf-test-repo"
Expand All @@ -1966,7 +1965,7 @@ func (s *S) TestGetLog(c *gocheck.C) {
c.Assert(errCreateCommit, gocheck.IsNil)
errCreateCommit = CreateCommit(bare, repo, file, object2)
c.Assert(errCreateCommit, gocheck.IsNil)
history, err := GetLog(repo, "HEAD", 1, "")
history, err := GetLogs(repo, "HEAD", 1, "")
c.Assert(err, gocheck.IsNil)
c.Assert(history.Commits, gocheck.HasLen, 1)
c.Assert(history.Commits[0].Ref, gocheck.Matches, "[a-f0-9]{40}")
Expand All @@ -1980,7 +1979,7 @@ func (s *S) TestGetLog(c *gocheck.C) {
c.Assert(history.Commits[0].CreatedAt, gocheck.Equals, history.Commits[0].Author.Date)
c.Assert(history.Next, gocheck.Matches, "[a-f0-9]{40}")
// Next
history, err = GetLog(repo, history.Next, 1, "")
history, err = GetLogs(repo, history.Next, 1, "")
c.Assert(err, gocheck.IsNil)
c.Assert(history.Commits, gocheck.HasLen, 1)
c.Assert(history.Commits[0].Ref, gocheck.Matches, "[a-f0-9]{40}")
Expand All @@ -1994,7 +1993,7 @@ func (s *S) TestGetLog(c *gocheck.C) {
c.Assert(history.Commits[0].CreatedAt, gocheck.Equals, history.Commits[0].Author.Date)
c.Assert(history.Next, gocheck.Matches, "[a-f0-9]{40}")
// Next
history, err = GetLog(repo, history.Next, 1, "")
history, err = GetLogs(repo, history.Next, 1, "")
c.Assert(err, gocheck.IsNil)
c.Assert(history.Commits, gocheck.HasLen, 1)
c.Assert(history.Commits[0].Ref, gocheck.Matches, "[a-f0-9]{40}")
Expand All @@ -2009,7 +2008,7 @@ func (s *S) TestGetLog(c *gocheck.C) {
c.Assert(history.Next, gocheck.Equals, "")
}

func (s *S) TestGetLogWithFile(c *gocheck.C) {
func (s *S) TestGetLogsWithFile(c *gocheck.C) {
oldBare := bare
bare = "/tmp"
repo := "gandalf-test-repo"
Expand All @@ -2027,7 +2026,7 @@ func (s *S) TestGetLogWithFile(c *gocheck.C) {
c.Assert(errCreateCommit, gocheck.IsNil)
errCreateCommit = CreateCommit(bare, repo, file, object2)
c.Assert(errCreateCommit, gocheck.IsNil)
history, err := GetLog(repo, "master", 1, "README")
history, err := GetLogs(repo, "master", 1, "README")
c.Assert(err, gocheck.IsNil)
c.Assert(history.Commits, gocheck.HasLen, 1)
c.Assert(history.Commits[0].Ref, gocheck.Matches, "[a-f0-9]{40}")
Expand Down
2 changes: 1 addition & 1 deletion user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (u *User) handleAssociatedRepositories() error {
//
// Stores the key in the user's document and write it in authorized_keys.
//
// Returns an error in case the user does not exists.
// Returns an error in case the user does not exist.
func AddKey(uName string, k map[string]string) error {
var u User
conn, err := db.Conn()
Expand Down
4 changes: 2 additions & 2 deletions user/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (s *S) TestAddKeyShouldWriteKeyInAuthorizedKeys(c *gocheck.C) {
c.Assert(content, gocheck.Equals, key.format())
}

func (s *S) TestAddKeyShouldReturnCustomErrorWhenUserDoesNotExists(c *gocheck.C) {
func (s *S) TestAddKeyShouldReturnCustomErrorWhenUserDoesNotExist(c *gocheck.C) {
err := AddKey("umi", map[string]string{"somekey": "ssh-rsa mykey umi@host"})
c.Assert(err, gocheck.Equals, ErrUserNotFound)
}
Expand Down Expand Up @@ -342,7 +342,7 @@ func (s *S) TestRemoveUnknownKeyFromUser(c *gocheck.C) {
c.Assert(err, gocheck.Equals, ErrKeyNotFound)
}

func (s *S) TestRemoveKeyShouldReturnFormatedErrorMsgWhenUserDoesNotExists(c *gocheck.C) {
func (s *S) TestRemoveKeyShouldReturnFormatedErrorMsgWhenUserDoesNotExist(c *gocheck.C) {
err := RemoveKey("luke", "homekey")
c.Assert(err, gocheck.Equals, ErrUserNotFound)
}

0 comments on commit dbb08dd

Please sign in to comment.