Adding upstream version 3.10.8.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
37e9b6d587
commit
03bfe4079e
356 changed files with 28857 additions and 0 deletions
68
forges/filesystem/pullrequest.go
Normal file
68
forges/filesystem/pullrequest.go
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Copyright Earl Warren <contact@earl-warren.org>
|
||||
// Copyright Loïc Dachary <loic@dachary.org>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"code.forgejo.org/f3/gof3/v3/f3"
|
||||
helper_pullrequest "code.forgejo.org/f3/gof3/v3/forges/helpers/pullrequest"
|
||||
"code.forgejo.org/f3/gof3/v3/id"
|
||||
"code.forgejo.org/f3/gof3/v3/tree/generic"
|
||||
)
|
||||
|
||||
type pullRequestDriver struct {
|
||||
nodeDriver
|
||||
h helper_pullrequest.Interface
|
||||
}
|
||||
|
||||
func newPullRequestDriver(ctx context.Context, content f3.Interface) generic.NodeDriverInterface {
|
||||
n := newNodeDriver(content).(*nodeDriver)
|
||||
r := &pullRequestDriver{
|
||||
nodeDriver: *n,
|
||||
}
|
||||
r.h = helper_pullrequest.NewHelper(ctx, r)
|
||||
return r
|
||||
}
|
||||
|
||||
func (o *pullRequestDriver) GetPullRequestPushRefs() []string {
|
||||
return []string{fmt.Sprintf("refs/f3/%s/head", o.GetNativeID())}
|
||||
}
|
||||
|
||||
func (o *pullRequestDriver) GetPullRequestRef() string {
|
||||
return fmt.Sprintf("refs/f3/%s/head", o.GetNativeID())
|
||||
}
|
||||
|
||||
func (o *pullRequestDriver) GetPullRequestHead() string {
|
||||
f := o.nodeDriver.content.(*f3.PullRequest)
|
||||
return f.Head.Ref
|
||||
}
|
||||
|
||||
func (o *pullRequestDriver) SetFetchFunc(fetchFunc func(ctx context.Context, url, ref string)) {
|
||||
f := o.nodeDriver.content.(*f3.PullRequest)
|
||||
f.FetchFunc = fetchFunc
|
||||
}
|
||||
|
||||
func (o *pullRequestDriver) Put(ctx context.Context) id.NodeID {
|
||||
return o.upsert(ctx)
|
||||
}
|
||||
|
||||
func (o *pullRequestDriver) Patch(ctx context.Context) {
|
||||
o.upsert(ctx)
|
||||
}
|
||||
|
||||
func (o *pullRequestDriver) upsert(ctx context.Context) id.NodeID {
|
||||
o.nodeDriver.upsert(ctx)
|
||||
return o.h.Upsert(ctx)
|
||||
}
|
||||
|
||||
func (o *pullRequestDriver) Get(ctx context.Context) bool {
|
||||
if o.nodeDriver.Get(ctx) {
|
||||
o.h.Get(ctx)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue