-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fixes #2738 - Adds the /git/tags API endpoint #7138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d7eda0e
Fixes #2738 - /git/tags API
richmahn 0fc1605
Merge remote-tracking branch 'upstream/master' into fix-2738-tag-api
richmahn 4b84785
proper URLs
richmahn ab588c7
Adds function comments
richmahn 716e76c
Updates swagger
richmahn 861df65
Removes newline from tag message
richmahn 157d6b6
Removes trailing newline from commit message
richmahn 41bb6aa
Adds integration test
richmahn fae950f
Removed debugging
richmahn 7013cce
Merge remote-tracking branch 'upstream/master' into fix-2738-tag-api
richmahn a5208ca
Adds tests
richmahn 171ea70
Fixes bug where multiple tags of same commit show wrong tag name
richmahn ad3f04c
Fix formatting
richmahn 582c6cc
Removes unused varaible
richmahn 9c52751
Fix to annotated tag function names and response
richmahn 3e7633b
Merge remote-tracking branch 'upstream/master' into fix-2738-tag-api
richmahn 1df581d
Update modules/git/repo_tag.go
richmahn 6547bfc
Uses TagPrefix
richmahn 90e5315
Uses TagPrefix
richmahn 1f8c122
Merge remote-tracking branch 'upstream/master' into fix-2738-tag-api
richmahn dcce6bf
Changes per review, better error handling for getting tag and commit IDs
richmahn 9bc4e19
Fix to getting commit ID
richmahn 49e4349
Fix to getting commit ID
richmahn 8897b75
Fix to getting commit ID
richmahn 0321844
Fix to getting commit ID
richmahn b23c6d0
Merge remote-tracking branch 'upstream/master' into fix-2738-tag-api
richmahn 0aeec96
Merge branch 'master' into fix-2738-tag-api
lunny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2018 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package integrations | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models" | ||
"code.gitea.io/gitea/modules/git" | ||
api "code.gitea.io/gitea/modules/structs" | ||
"code.gitea.io/gitea/modules/util" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAPIGitTags(t *testing.T) { | ||
prepareTestEnv(t) | ||
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) | ||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) | ||
// Login as User2. | ||
session := loginUser(t, user.Name) | ||
token := getTokenForLoggedInUser(t, session) | ||
|
||
// Set up git config for the tagger | ||
git.NewCommand("config", "user.name", user.Name).RunInDir(repo.RepoPath()) | ||
git.NewCommand("config", "user.email", user.Email).RunInDir(repo.RepoPath()) | ||
|
||
gitRepo, _ := git.OpenRepository(repo.RepoPath()) | ||
commit, _ := gitRepo.GetBranchCommit("master") | ||
lTagName := "lightweightTag" | ||
gitRepo.CreateTag(lTagName, commit.ID.String()) | ||
|
||
aTagName := "annotatedTag" | ||
aTagMessage := "my annotated message" | ||
gitRepo.CreateAnnotatedTag(aTagName, aTagMessage, commit.ID.String()) | ||
aTag, _ := gitRepo.GetTag(aTagName) | ||
|
||
// SHOULD work for annotated tags | ||
req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/tags/%s?token=%s", user.Name, repo.Name, aTag.ID.String(), token) | ||
res := session.MakeRequest(t, req, http.StatusOK) | ||
|
||
var tag *api.AnnotatedTag | ||
DecodeJSON(t, res, &tag) | ||
|
||
assert.Equal(t, aTagName, tag.Tag) | ||
assert.Equal(t, aTag.ID.String(), tag.SHA) | ||
assert.Equal(t, commit.ID.String(), tag.Object.SHA) | ||
assert.Equal(t, aTagMessage, tag.Message) | ||
assert.Equal(t, user.Name, tag.Tagger.Name) | ||
assert.Equal(t, user.Email, tag.Tagger.Email) | ||
assert.Equal(t, util.URLJoin(repo.APIURL(), "git/tags", aTag.ID.String()), tag.URL) | ||
|
||
// Should NOT work for lightweight tags | ||
badReq := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/git/tags/%s?token=%s", user.Name, repo.Name, commit.ID.String(), token) | ||
session.MakeRequest(t, badReq, http.StatusBadRequest) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.