summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-02-26 07:32:22 +0100
committerGitHub <noreply@github.com>2020-02-26 03:32:22 -0300
commit084a2b00268ed561f59ac19b1b6660a3c58573b3 (patch)
tree5474cb8c1bd5a16251edf46cd99d54757e3ebc0c /modules
parente5944a9521102c4917399a6550a0756919527944 (diff)
downloadgitea-084a2b00268ed561f59ac19b1b6660a3c58573b3.tar.gz
gitea-084a2b00268ed561f59ac19b1b6660a3c58573b3.zip
Code Refactor of IssueWatch related things (#10401)
* refactor * optimize * remove Iretating function LoadWatchUsers do not load Users into IW object and it is used only in api ... so move this logic * remove unessesary * Apply suggestions from code review Thx Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * make Tests more robust * fix rebase * restart CI * CI no dont hit sqlites deadlock Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/git/repo_branch.go3
-rw-r--r--modules/test/context_tests.go7
2 files changed, 8 insertions, 2 deletions
diff --git a/modules/git/repo_branch.go b/modules/git/repo_branch.go
index e79bab76a6..3d0e6497ed 100644
--- a/modules/git/repo_branch.go
+++ b/modules/git/repo_branch.go
@@ -48,6 +48,9 @@ type Branch struct {
// GetHEADBranch returns corresponding branch of HEAD.
func (repo *Repository) GetHEADBranch() (*Branch, error) {
+ if repo == nil {
+ return nil, fmt.Errorf("nil repo")
+ }
stdout, err := NewCommand("symbolic-ref", "HEAD").RunInDir(repo.Path)
if err != nil {
return nil, err
diff --git a/modules/test/context_tests.go b/modules/test/context_tests.go
index cf9c5fbc54..f9f0ec5d42 100644
--- a/modules/test/context_tests.go
+++ b/modules/test/context_tests.go
@@ -58,8 +58,11 @@ func LoadRepoCommit(t *testing.T, ctx *context.Context) {
defer gitRepo.Close()
branch, err := gitRepo.GetHEADBranch()
assert.NoError(t, err)
- ctx.Repo.Commit, err = gitRepo.GetBranchCommit(branch.Name)
- assert.NoError(t, err)
+ assert.NotNil(t, branch)
+ if branch != nil {
+ ctx.Repo.Commit, err = gitRepo.GetBranchCommit(branch.Name)
+ assert.NoError(t, err)
+ }
}
// LoadUser load a user into a test context.