-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Use gitrepo.Repository instead of wikipath #35398
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
Open
lunny
wants to merge
27
commits into
go-gitea:main
Choose a base branch
from
lunny:lunny/remove_wiki_path_ref
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+248
−171
Open
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
e5b8200
Use gitrepo.Repository instead of most of wikipath
lunny 02d4f0f
Fix lint
lunny 499f969
Fix bug
lunny 6422004
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny ff860d1
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 5b43cff
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 2b169b9
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny f8fd517
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny f32dd3c
Merge branch 'lunny/remove_wiki_path_ref' of github.com:lunny/gitea i…
lunny 9ea7ab7
Remove wikipath method
lunny cbfe9ac
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny b7c2f08
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 4396437
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 4d0582a
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny e527a3d
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 214d007
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 51ee9fd
Merge branch 'lunny/remove_wiki_path_ref' of github.com:lunny/gitea i…
lunny 3b625fd
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 06271bd
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 5234986
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 37e210f
Merge branch 'lunny/remove_wiki_path_ref' of github.com:lunny/gitea i…
lunny d2fc9d2
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 494f563
remove unnecessary code
lunny 156ef6a
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 1096c1e
Merge branch 'lunny/remove_wiki_path_ref' of github.com:lunny/gitea i…
lunny e0488a0
Merge branch 'main' into lunny/remove_wiki_path_ref
lunny 4315055
Merge branch 'main' into lunny/remove_wiki_path_ref
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 |
---|---|---|
|
@@ -4,12 +4,10 @@ | |
package repo_test | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
repo_model "code.gitea.io/gitea/models/repo" | ||
"code.gitea.io/gitea/models/unittest" | ||
"code.gitea.io/gitea/modules/setting" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
@@ -22,16 +20,3 @@ func TestRepository_WikiCloneLink(t *testing.T) { | |
assert.Equal(t, "ssh://[email protected]:3000/user2/repo1.wiki.git", cloneLink.SSH) | ||
assert.Equal(t, "https://try.gitea.io/user2/repo1.wiki.git", cloneLink.HTTPS) | ||
} | ||
|
||
func TestWikiPath(t *testing.T) { | ||
assert.NoError(t, unittest.PrepareTestDatabase()) | ||
expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git") | ||
assert.Equal(t, expected, repo_model.WikiPath("user2", "repo1")) | ||
} | ||
|
||
func TestRepository_WikiPath(t *testing.T) { | ||
assert.NoError(t, unittest.PrepareTestDatabase()) | ||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) | ||
expected := filepath.Join(setting.RepoRootPath, "user2/repo1.wiki.git") | ||
assert.Equal(t, expected, repo.WikiPath()) | ||
} |
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,18 @@ | ||
// Copyright 2025 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package gitrepo | ||
|
||
import ( | ||
"context" | ||
|
||
"code.gitea.io/gitea/modules/git" | ||
) | ||
|
||
func CloneIn(ctx context.Context, dstRepo Repository, from string, opts git.CloneRepoOptions) error { | ||
return git.Clone(ctx, from, repoPath(dstRepo), opts) | ||
} | ||
|
||
func CloneOut(ctx context.Context, fromRepo Repository, to string, opts git.CloneRepoOptions) error { | ||
return git.Clone(ctx, repoPath(fromRepo), to, opts) | ||
} |
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,14 @@ | ||
// Copyright 2025 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package gitrepo | ||
|
||
import ( | ||
"context" | ||
|
||
"code.gitea.io/gitea/modules/git" | ||
) | ||
|
||
func WriteCommitGraph(ctx context.Context, repo Repository) error { | ||
return git.WriteCommitGraph(ctx, repoPath(repo)) | ||
} |
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,52 @@ | ||
// Copyright 2025 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package gitrepo | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"io" | ||
"os" | ||
|
||
"code.gitea.io/gitea/modules/git/gitcmd" | ||
) | ||
|
||
func serviceCmd(service string) *gitcmd.Command { | ||
switch service { | ||
case "receive-pack": | ||
return gitcmd.NewCommand("receive-pack") | ||
case "upload-pack": | ||
return gitcmd.NewCommand("upload-pack") | ||
default: | ||
// the service should be checked before invoking this function | ||
panic("unknown service: " + service) | ||
} | ||
} | ||
|
||
func StatelessRPC(ctx context.Context, storageRepo Repository, service string, extraEnvs []string, input io.Reader, output io.Writer) (string, error) { | ||
var stderr bytes.Buffer | ||
if err := serviceCmd(service). | ||
AddArguments("--stateless-rpc"). | ||
AddDynamicArguments(repoPath(storageRepo)). | ||
Run(ctx, &gitcmd.RunOpts{ | ||
Dir: repoPath(storageRepo), | ||
Env: append(os.Environ(), extraEnvs...), | ||
Stdout: output, | ||
Stdin: input, | ||
Stderr: &stderr, | ||
UseContextTimeout: true, | ||
}); err != nil { | ||
return stderr.String(), err | ||
} | ||
return "", nil | ||
} | ||
|
||
func StatelessRPCAdvertiseRefs(ctx context.Context, storageRepo Repository, service string, extraEnvs []string) ([]byte, error) { | ||
refs, _, err := serviceCmd(service).AddArguments("--stateless-rpc", "--advertise-refs", "."). | ||
RunStdBytes(ctx, &gitcmd.RunOpts{ | ||
Dir: repoPath(storageRepo), | ||
Env: append(os.Environ(), extraEnvs...), | ||
}) | ||
return refs, err | ||
} |
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,14 @@ | ||
// Copyright 2025 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package gitrepo | ||
|
||
import ( | ||
"context" | ||
|
||
"code.gitea.io/gitea/modules/git" | ||
) | ||
|
||
func Push(ctx context.Context, repo Repository, opts git.PushOptions) error { | ||
return git.Push(ctx, repoPath(repo), opts) | ||
} |
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,14 @@ | ||
// Copyright 2025 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package gitrepo | ||
|
||
import ( | ||
"context" | ||
|
||
"code.gitea.io/gitea/modules/git" | ||
) | ||
|
||
func GetSigningKey(ctx context.Context, repo Repository) (*git.SigningKey, *git.Signature) { | ||
return git.GetSigningKey(ctx, repoPath(repo)) | ||
} |
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.