mirror of
https://github.com/harness/drone.git
synced 2025-05-04 18:00:16 +08:00

Adds the following: - Add GetContent API (with gitrpc, proto, gitadapter changes) - Add ListCommits API (with gitrpc, proto, gitadapter changes) - DefaultBranch (to repo table in DB, update branch in git-repo, have default value in config)
99 lines
1.9 KiB
Go
99 lines
1.9 KiB
Go
// Copyright 2022 Harness Inc. All rights reserved.
|
|
// Use of this source code is governed by the Polyform Free Trial License
|
|
// that can be found in the LICENSE.md file for this repository.
|
|
|
|
package gitrpc
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type cloneRepoOption struct {
|
|
timeout time.Duration
|
|
mirror bool
|
|
bare bool
|
|
quiet bool
|
|
branch string
|
|
shared bool
|
|
noCheckout bool
|
|
depth int
|
|
filter string
|
|
skipTLSVerify bool
|
|
}
|
|
type commit struct {
|
|
sha string
|
|
title string
|
|
message string
|
|
author signature
|
|
committer signature
|
|
}
|
|
|
|
// signature represents the Author or Committer information.
|
|
type signature struct {
|
|
identity identity
|
|
// When is the timestamp of the signature.
|
|
when time.Time
|
|
}
|
|
|
|
type identity struct {
|
|
name string
|
|
email string
|
|
}
|
|
|
|
type commitChangesOptions struct {
|
|
committer signature
|
|
author signature
|
|
message string
|
|
}
|
|
|
|
type pushOptions struct {
|
|
remote string
|
|
branch string
|
|
force bool
|
|
mirror bool
|
|
env []string
|
|
timeout time.Duration
|
|
}
|
|
|
|
type treeNode struct {
|
|
nodeType treeNodeType
|
|
mode treeNodeMode
|
|
sha string
|
|
name string
|
|
path string
|
|
}
|
|
|
|
// treeNodeType specifies the different types of nodes in a git tree.
|
|
// IMPORTANT: has to be consistent with rpc.TreeNodeType (proto).
|
|
type treeNodeType int
|
|
|
|
const (
|
|
treeNodeTypeTree treeNodeType = iota
|
|
treeNodeTypeBlob
|
|
treeNodeTypeCommit
|
|
)
|
|
|
|
// treeNodeType specifies the different modes of a node in a git tree.
|
|
// IMPORTANT: has to be consistent with rpc.TreeNodeMode (proto).
|
|
type treeNodeMode int
|
|
|
|
const (
|
|
treeNodeModeFile treeNodeMode = iota
|
|
treeNodeModeSymlink
|
|
treeNodeModeExec
|
|
treeNodeModeTree
|
|
treeNodeModeCommit
|
|
)
|
|
|
|
type submodule struct {
|
|
name string
|
|
url string
|
|
}
|
|
|
|
type blob struct {
|
|
size int64
|
|
// content contains the content of the blob
|
|
// NOTE: can be only partial content - compare len(.content) with .size
|
|
content []byte
|
|
}
|