Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork6.3k
Updated agit doc for git-repo#27014
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Added basic reference instructions to unblock `git-repo` users who don't use Gerrit but use Gitea.
| 1. Create a file in`$GITEA_CUSTOM/public/` called`ssh_info` | ||
| 2. Populate it with`{"type":"agit","version":2}` | ||
| 3. Add a rewrite rule for your reverse proxy which rewrites the request path equaling`/ssh_info` to`/assets/ssh_info` |
silverwindSep 11, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Don't we already provide a mechanism to put files into root, like/robots.txt? Or maybe that path is already occupied, not familiar with/ssh_info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The only one I could find was/assets/<file>, andrepo/git-repo expect it to be at the root of the host 🤷🏼♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The quite old "assets" handler logic is: if local file exists, then use it, otherwise, pass it to other handles.
However, the logic has been changed long time ago, the local file doesn't have higher priority than other handlers.
For example: if you have a file in{Custom}/public/my-name and an orgmy-name
- For quite old logic (very long time ago): the local file
{Custom}/public/my-nameis served- Users could serve any custom files without reverse proxy tweaks.
- For current logic (has been changed long time ago): the org
my-nameis severed.
TBH, the quite old logic looks good to me, while I guess some nice features were changed unintentionally by many round iterations.
wxiaoguangSep 12, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There is special handling for robots.txt to remain under the root path. Maybe we could include the ssh_info in the binary directly? It would require reserving the "ssh_info" username, but I think that would be acceptable as a "breaking" change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I would prefer to take the "quite old logic" back, then end users could still have the ability to serve any file in the web root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hmm, gitea has defined/ssh_info router, but the type has been defined asgitea (example:https://try.gitea.io/ssh_info), That's because I'm not sureagit flow has been fully implement. looks need more work. and I hasn't checking whether gitea can be used withgit-repo tool also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
whether gitea can be used with
git-repotool also.
I'm working through why it hasn't been working as intended, and this is what I've found so far. If the router has implemented/ssh_info but it's wrong, then we should fix it. It's ultimately something from Gerrit:
lunny commentedSep 13, 2023
Please send the patch to v1.21(main branch) first |
wxiaoguang commentedSep 13, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Is there a clear conclusion? Before doing future changes, I guess it should clarify the details first? There are 2 problems:
|
a1012112796 commentedSep 14, 2023
@mxplusb maybe you need this plugin, ref:https://github.com/alibaba/git-repo-go/blob/master/helper/proto-external.go package mainimport ("bufio""encoding/json""errors""fmt""io""log""os""strings""github.com/alibaba/git-repo-go/cap""github.com/alibaba/git-repo-go/config""github.com/alibaba/git-repo-go/encode""github.com/alibaba/git-repo-go/helper""github.com/urfave/cli/v2")funcmain() {app:=&cli.App{Name:"git-repo-helper-proto-gitea",Usage:"gitea protocol helper for git repo",Action:cmdMain,Flags: []cli.Flag{&cli.BoolFlag{Name:"upload",Usage:"for upload hook",},&cli.BoolFlag{Name:"download",Usage:"for download hook",},&cli.Int64Flag{Name:"version",Usage:"hook version",},},}iferr:=app.Run(os.Args);err!=nil {log.Fatal(err)}}funcgetGitPushCommand(o*config.UploadOptions) (*helper.GitPushCommand,error) {var (gitPushCmd= helper.GitPushCommand{})cmds:= []string{"git","push"}ifo.RemoteURL=="" {returnnil,errors.New("empty review url for helper")}gitURL:=config.ParseGitURL(o.RemoteURL)ifgitURL==nil|| (gitURL.Proto!="ssh"&&gitURL.Proto!="http"&&gitURL.Proto!="https") {returnnil,fmt.Errorf("bad review URL: %s",o.RemoteURL)}if!cap.GitCanPushOptions() {log.Fatalln("cannot send push options, for your git version is too low")}for_,pushOption:=rangeo.PushOptions {cmds=append(cmds,"-o",pushOption)}refSpec:=""localBranch:=strings.TrimPrefix(o.LocalBranch,config.RefsHeads)destBranch:=strings.TrimPrefix(o.DestBranch,config.RefsHeads)iflocalBranch=="" {refSpec="HEAD"}else {refSpec=config.RefsHeads+localBranch}if!o.CodeReview.Empty() {log.Fatalln("gitea not support for-review now")}else {refSpec+=fmt.Sprintf(":refs/for/%s/%s",destBranch,localBranch)}ifo.Title!="" {cmds=append(cmds,"-o","title="+encode.B64Encode(o.Title))}ifo.Description!="" {cmds=append(cmds,"-o","description="+encode.B64Encode(o.Description))}// TODO:// if o.Issue != "" {// cmds = append(cmds, "-o", "issue="+encode.B64Encode(o.Issue))// }// if o.People != nil && len(o.People) > 0 && len(o.People[0]) > 0 {// reviewers := strings.Join(o.People[0], ",")// cmds = append(cmds, "-o", "reviewers="+encode.B64Encode(reviewers))// }// if o.People != nil && len(o.People) > 1 && len(o.People[1]) > 0 {// cc := strings.Join(o.People[1], ",")// cmds = append(cmds, "-o", "cc="+encode.B64Encode(cc))// }// if o.NoEmails {// cmds = append(cmds, "-o", "notify=no")// }// if o.Private {// cmds = append(cmds, "-o", "private=yes")// }// if o.WIP {// cmds = append(cmds, "-o", "wip=yes")// }// if o.OldOid != "" {// cmds = append(cmds, "-o", "old-oid="+o.OldOid)// }ifo.RemoteName!="" {cmds=append(cmds,o.RemoteName)}else {cmds=append(cmds,o.RemoteURL)}cmds=append(cmds,refSpec)gitPushCmd.Cmd=cmds[0]gitPushCmd.Args=cmds[1:]return&gitPushCmd,nil}funccmdUpload()error {log.Printf("cmdUpload ...\n")input,err:=io.ReadAll(os.Stdin)iferr!=nil {returnerr}cfg:= config.UploadOptions{}err=json.Unmarshal(input,&cfg)iferr!=nil {log.Printf("Error: cmdUpload: %v\n",err)returnerr}log.Printf("Debug: cmdUpload: %#v\n",cfg)result,err:=getGitPushCommand(&cfg)iferr!=nil {returnerr}resultBytes,err:=json.Marshal(result)iferr!=nil {returnerr}_,err=os.Stdout.Write(resultBytes)returnerr}funccmdDownload()error {scan:=bufio.NewScanner(os.Stdin)if!scan.Scan() {returnerrors.New("no input data")}parts:=strings.SplitN(scan.Text()," ",3)iflen(parts)!=2 {returnerrors.New("no enough params")}log.Println("cmdDownload: ",parts[0],parts[1])fmt.Printf("refs/pull/%s/head\n",parts[0])returnnil}varlogFp*os.FiletypeemptyWriterstruct{}func (e*emptyWriter)Write(p []byte) (nint,errerror) {returnlen(p),nil}funcinitLogFile()error {debugFile:=os.Getenv("GIT_REPO_GITEA_DEBUG")iflen(debugFile)==0 {log.SetOutput(&emptyWriter{})returnnil}varerrerrorlogFp,err=os.OpenFile(debugFile,os.O_CREATE|os.O_WRONLY|os.O_TRUNC,0o644)iferr==nil {log.SetOutput(logFp)}returnerr}funccmdMain(ctx*cli.Context)error {iferr:=initLogFile();err!=nil {returnerr}deferfunc() {iflogFp!=nil {logFp.Close()}}()ifctx.Bool("upload") {returncmdUpload()}ifctx.Bool("download") {returncmdDownload()}returnnil} |
Uh oh!
There was an error while loading.Please reload this page.
Added basic reference instructions to unblock
git-repousers who don't use Gerrit but use Gitea.