common

package
v0.0.0-...-90c29cc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 34 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ChangelogFileName = "CHANGELOG.md"
)

Variables

This section is empty.

Functions

func AddChangelogToFile

func AddChangelogToFile(changelog *Changelog, version *semver.Version, packageRootPath, releaseDate string) (string, error)

add new changelog md to changelog file

func AddTagSet

func AddTagSet(path, tag string) error

AddTagSet add tag in file

func ChangeConfigWithCommitID

func ChangeConfigWithCommitID(path, repoURL, commitID, specRPName string) error

replace repo URL and commit id in autorest.md file

func ChangeConfigWithLocalPath

func ChangeConfigWithLocalPath(path, readmeFile, readmeGoFile string) error

replace repo commit with local path in autorest.md file

func CleanSDKGeneratedFiles

func CleanSDKGeneratedFiles(path string) error

remove all sdk generated files in given path

func ContainsPreviewAPIVersion

func ContainsPreviewAPIVersion(packagePath string) (bool, error)

func EnumFilter

func EnumFilter(changelog *Changelog)

func ExecuteAddIssueComment

func ExecuteAddIssueComment(path, repoOwner, repoName, issueNumber, comment, authToken string) error

func ExecuteAddIssueLabels

func ExecuteAddIssueLabels(path, repoOwner, repoName, issueNumber, authToken string, labels []string) error

func ExecuteCreatePullRequest

func ExecuteCreatePullRequest(path, repoOwner, repoName, prOwner, prBranch, prTitle, prBody, authToken, prLabels string) (string, error)

func ExecuteExampleGenerate

func ExecuteExampleGenerate(path, packagePath, flag string) error

execute `pwsh Invoke-MgmtTestgen` command and fetch result

func ExecuteGitPush

func ExecuteGitPush(path, remoteName, branchName string) (string, error)

func ExecuteGo

func ExecuteGo(dir string, args ...string) error

func ExecuteGoFmt

func ExecuteGoFmt(dir string, args ...string) error

func ExecuteGoGenerate

func ExecuteGoGenerate(path string) error

execute `go generate` command and fetch result

func ExecuteGoimports

func ExecuteGoimports(path string) error

execute `goimports` command and fetch result

func ExecuteTspClient

func ExecuteTspClient(path string, args ...string) error

execute tsp-client command

func ExecuteTypeSpecGenerate

func ExecuteTypeSpecGenerate(ctx *GenerateContext, emitOptions string, tspClientOptions []string) error

func FilterChangelog

func FilterChangelog(changelog *Changelog, opts ...func(changelog *Changelog))

func FuncFilter

func FuncFilter(changelog *Changelog)

func GetAllVersionTags

func GetAllVersionTags(packageModuleRelativePath string) ([]string, error)

func GetAlwaysSetBodyParamRequiredFlag

func GetAlwaysSetBodyParamRequiredFlag(path string) (string, error)

func GetExportsFromTag

func GetExportsFromTag(sdkRepo repo.SDKRepository, packagePath, tag string) (*exports.Content, error)

func GetPreviousVersionTag

func GetPreviousVersionTag(isCurrentPreview bool, allReleases []string) string

func GetSDKRepo

func GetSDKRepo(sdkRepoParam, sdkRepoURL string) (repo.SDKRepository, error)

func GetSpecCommit

func GetSpecCommit(specRepoParam string) (string, error)

func GetSpecRpName

func GetSpecRpName(packageRootPath string) (string, error)

get swagger rp folder name from autorest.md file

func GetTag

func GetTag(path string) (string, error)

func InterfaceToAnyFilter

func InterfaceToAnyFilter(changelog *Changelog)

func IsBetaVersion

func IsBetaVersion(v string) (bool, error)

func LROFilter

func LROFilter(changelog *Changelog)

LROFilter LROFilter after OperationFilter

func MarshalUnmarshalFilter

func MarshalUnmarshalFilter(changelog *Changelog)

func NonExportedFilter

func NonExportedFilter(changelog *Changelog)

func PageableFilter

func PageableFilter(changelog *Changelog)

PageableFilter PageableFilter after OperationFilter

func ReadV2ModuleNameToGetNamespace

func ReadV2ModuleNameToGetNamespace(path string) (map[string][]PackageInfo, error)

reads from readme.go.md, parses the `track2` section to get module and package name

func RemoveTagSet

func RemoveTagSet(path string) error

RemoveTagSet delete tag set in config file

func ReplaceConstModuleVersion

func ReplaceConstModuleVersion(packagePath string, newVersion string) error

func ReplaceImport

func ReplaceImport(sourceFile string, baseModule string, majorVersion int64) error

func ReplaceModule

func ReplaceModule(newVersion *semver.Version, packagePath, baseModule string, suffixs ...string) error

func ReplaceNewClientNamePlaceholder

func ReplaceNewClientNamePlaceholder(packageRootPath string, exports exports.Content) error

replace `{{NewClientName}}` placeholder in README.md by first func name according to `^New.+Method$` pattern

func ReplaceReadmeNewClientName

func ReplaceReadmeNewClientName(packageRootPath string, exports exports.Content) error

func ReplaceVersion

func ReplaceVersion(packageRootPath string, newVersion string) error

replace version: use `module-version: ` prefix to locate version in autorest.md file, use version = "v*.*.*" regrex to locate version in constants.go file

func SortFuncItem

func SortFuncItem[T delta.FuncSig | exports.Func](change map[string]T) []string

func UpdateModuleDefinition

func UpdateModuleDefinition(packageRootPath, packageModuleRelativePath string, version *semver.Version) error

func UpdateOnboardChangelogVersion

func UpdateOnboardChangelogVersion(packageRootPath, versionNumber string) error

Types

type Changelog

type Changelog struct {
	// NewPackage is true if this package does not exist in the old version
	NewPackage bool
	// RemovedPackage is true if this package does not exist in the new version
	RemovedPackage bool
	// Modified contains the details of a modified package. This is nil when either NewPackage or RemovedPackage is true
	Modified *report.Package
}

Changelog describes the changelog generated for a package.

func GetChangelogForPackage

func GetChangelogForPackage(lhs, rhs *exports.Content) (*Changelog, error)

GetChangelogForPackage generates the changelog report with the given two Contents

func (Changelog) GetBreakingChangeItems

func (c Changelog) GetBreakingChangeItems() []string

GetBreakingChangeItems returns an array of the breaking change items

func (Changelog) GetChangeSummary

func (c Changelog) GetChangeSummary() string

Seperate change summary text get

func (Changelog) HasBreakingChanges

func (c Changelog) HasBreakingChanges() bool

HasBreakingChanges returns if this report of changelog contains breaking changes

func (Changelog) String

func (c Changelog) String() string

String ...

func (Changelog) ToCompactMarkdown

func (c Changelog) ToCompactMarkdown() string

ToCompactMarkdown returns the markdown string of this changelog but more compact

func (Changelog) ToMarkdown

func (c Changelog) ToMarkdown() string

ToMarkdown returns the markdown string of this changelog

type GenerateContext

type GenerateContext struct {
	SDKPath           string
	SDKRepo           *repo.SDKRepository
	SpecPath          string
	SpecCommitHash    string
	SpecReadmeFile    string
	SpecReadmeGoFile  string
	SpecRepoURL       string
	UpdateSpecVersion bool

	// typespec
	TypeSpecConfig *typespec.TypeSpecConfig
}

func (*GenerateContext) GenerateForAutomation

func (ctx *GenerateContext) GenerateForAutomation(readme, repo, goVersion string) ([]GenerateResult, []error)

func (*GenerateContext) GenerateForSingleRPNamespace

func (ctx *GenerateContext) GenerateForSingleRPNamespace(generateParam *GenerateParam) (*GenerateResult, error)

func (*GenerateContext) GenerateForTypeSpec

func (ctx *GenerateContext) GenerateForTypeSpec(generateParam *GenerateParam, packageModuleRelativePath string) (*GenerateResult, error)

type GenerateParam

type GenerateParam struct {
	RPName               string
	NamespaceName        string
	NamespaceConfig      string
	SpecificVersion      string
	SpecificPackageTitle string
	SpecRPName           string
	ReleaseDate          string
	SkipGenerateExample  bool
	GoVersion            string
	RemoveTagSet         bool
	ForceStableVersion   bool
	TypeSpecEmitOption   string
	TspClientOptions     []string
}

type GenerateResult

type GenerateResult struct {
	Version           string
	RPName            string
	PackageName       string
	PackageAbsPath    string
	Changelog         Changelog
	ChangelogMD       string
	PullRequestLabels string
}

type PackageInfo

type PackageInfo struct {
	Name        string
	Config      string
	SpecName    string
	RequestLink string
	Tag         string
	ReleaseDate *time.Time
}

type PullRequestLabel

type PullRequestLabel string
const (
	StableLabel                PullRequestLabel = "Stable"
	BetaLabel                  PullRequestLabel = "Beta"
	FirstGALabel               PullRequestLabel = "FirstGA"
	FirstGABreakingChangeLabel PullRequestLabel = "FirstGA,BreakingChange"
	FirstBetaLabel             PullRequestLabel = "FirstBeta"
	StableBreakingChangeLabel  PullRequestLabel = "Stable,BreakingChange"
	BetaBreakingChangeLabel    PullRequestLabel = "Beta,BreakingChange"
)

func CalculateNewVersion

func CalculateNewVersion(changelog *Changelog, previousVersion string, isCurrentPreview bool) (*semver.Version, PullRequestLabel, error)

calculate new version by changelog using semver package

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL