Add checkbox to search for all the branches by commit message (#813)

and updating the vendor directory
This commit is contained in:
Zsombor 2017-02-05 15:43:28 +01:00 committed by Lunny Xiao
parent f35b20b042
commit e388db311b
9 changed files with 39 additions and 18 deletions

View File

@ -513,6 +513,7 @@ editor.upload_files_to_dir = Upload files to '%s'
commits.commits = Commits
commits.search = Search commits
commits.search_all = All
commits.find = Find
commits.author = Author
commits.message = Message

View File

@ -111,8 +111,9 @@ func SearchCommits(ctx *context.Context) {
ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.BranchName)
return
}
all := ctx.QueryBool("all")
commits, err := ctx.Repo.Commit.SearchCommits(keyword)
commits, err := ctx.Repo.Commit.SearchCommits(keyword, all)
if err != nil {
ctx.Handle(500, "SearchCommits", err)
return
@ -122,6 +123,9 @@ func SearchCommits(ctx *context.Context) {
ctx.Data["Commits"] = commits
ctx.Data["Keyword"] = keyword
if all {
ctx.Data["All"] = "checked"
}
ctx.Data["Username"] = ctx.Repo.Owner.Name
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
ctx.Data["CommitCount"] = commits.Len()

View File

@ -6,6 +6,7 @@
<div class="ui tiny search input">
<input name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" autofocus>
</div>
<input type="checkbox" name="all" id="all" value="true" {{.All}}><label for="all">{{.i18n.Tr "repo.commits.search_all"}}</label>
<button class="ui black tiny button" data-panel="#add-deploy-key-panel">{{.i18n.Tr "repo.commits.find"}}</button>
</form>
</div>

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
Alexey Makhov <amakhov@avito.ru> (@makhov)
Andrey Nering <andrey.nering@gmail.com> (@andreynering)
Bo-Yi Wu <appleboy.tw@gmail.com> (@appleboy)
Ethan Koenig <ethantkoenig@gmail.com> (@ethantkoenig)
Kees de Vries <bouwko@gmail.com> (@Bwko)
Kim Carlbäcker <kim.carlbacker@gmail.com> (@bkcsoft)
LefsFlare <nobody@nobody.tld> (@LefsFlarey)

4
vendor/code.gitea.io/git/commit.go generated vendored
View File

@ -198,8 +198,8 @@ func (c *Commit) CommitsBeforeUntil(commitID string) (*list.List, error) {
}
// SearchCommits returns the commits match the keyword before current revision
func (c *Commit) SearchCommits(keyword string) (*list.List, error) {
return c.repo.searchCommits(c.ID, keyword)
func (c *Commit) SearchCommits(keyword string, all bool) (*list.List, error) {
return c.repo.searchCommits(c.ID, keyword, all)
}
// GetFilesChangedSinceCommit get all changed file names between pastCommit to current revision

View File

@ -102,6 +102,16 @@ func (repo *Repository) DeleteBranch(name string, opts DeleteBranchOptions) erro
return err
}
// CreateBranch create a new branch
func (repo *Repository) CreateBranch(branch, newBranch string) error {
cmd := NewCommand("branch")
cmd.AddArguments(branch, newBranch)
_, err := cmd.RunInDir(repo.Path)
return err
}
// AddRemote adds a new remote to repository.
func (repo *Repository) AddRemote(name, url string, fetch bool) error {
cmd := NewCommand("remote", "add")

View File

@ -196,8 +196,12 @@ func (repo *Repository) commitsByRange(id SHA1, page int) (*list.List, error) {
return repo.parsePrettyFormatLogToList(stdout)
}
func (repo *Repository) searchCommits(id SHA1, keyword string) (*list.List, error) {
stdout, err := NewCommand("log", id.String(), "-100", "-i", "--grep="+keyword, prettyLogFormat).RunInDirBytes(repo.Path)
func (repo *Repository) searchCommits(id SHA1, keyword string, all bool) (*list.List, error) {
cmd := NewCommand("log", id.String(), "-100", "-i", "--grep="+keyword, prettyLogFormat)
if all {
cmd.AddArguments("--all")
}
stdout, err := cmd.RunInDirBytes(repo.Path)
if err != nil {
return nil, err
}

6
vendor/vendor.json vendored
View File

@ -3,10 +3,10 @@
"ignore": "test",
"package": [
{
"checksumSHA1": "P2wIRW07gnEgqLZAcg7bz+Jw9Oc=",
"checksumSHA1": "km1AOUs34DCwgXT55fh6PrkPdiU=",
"path": "code.gitea.io/git",
"revision": "7477742b3c79d36d099baaf614864b6bbdfdecca",
"revisionTime": "2017-01-09T15:46:57Z"
"revision": "dd951bf625ebf5c16ef403f681aaec6c34324bca",
"revisionTime": "2017-02-05T02:50:57Z"
},
{
"checksumSHA1": "BKj0haFTDebzdC2nACpoGzp3s8A=",