本文整理汇总了Golang中github.com/salsaflow/salsaflow/log.Log函数的典型用法代码示例。如果您正苦于以下问题:Golang Log函数的具体用法?Golang Log怎么用?Golang Log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: run
func run(cmd *gocli.Command, args []string) {
if len(args) != 0 {
cmd.Usage()
os.Exit(2)
}
upgraded, err := pkg.Upgrade(&pkg.InstallOptions{
GitHubOwner: flagOwner,
GitHubRepo: flagRepo,
})
if err != nil {
if err == pkg.ErrAborted {
fmt.Println("\nYour wish is my command, exiting now!")
return
}
errs.Fatal(err)
}
if upgraded {
log.Log("SalsaFlow was upgraded successfully")
} else {
log.Log("SalsaFlow is up to date")
asciiart.PrintThumbsUp()
fmt.Println()
}
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:26,代码来源:command.go
示例2: extendReviewRequest
// extendReviewRequest is a general function that can be used to extend
// the given review issue with the given list of commits.
func extendReviewRequest(
config Config,
owner string,
repo string,
issue *github.Issue,
commits []*git.Commit,
opts map[string]interface{},
) error {
var (
issueNum = *issue.Number
issueBody = *issue.Body
bodyBuffer = bytes.NewBufferString(issueBody)
addedCommits = make([]*git.Commit, 0, len(commits))
)
for _, commit := range commits {
// Make sure the commit is not added yet.
commitString := fmt.Sprintf("] %v: %v", commit.SHA, commit.MessageTitle)
if strings.Contains(issueBody, commitString) {
log.Log(fmt.Sprintf("Commit %v already listed in issue #%v", commit.SHA, issueNum))
continue
}
// Extend the issue body.
addedCommits = append(addedCommits, commit)
fmt.Fprintf(bodyBuffer, "\n- [ ] %v: %v", commit.SHA, commit.MessageTitle)
}
if len(addedCommits) == 0 {
log.Log(fmt.Sprintf("All commits already listed in issue #%v", issueNum))
return nil
}
// Edit the issue.
task := fmt.Sprintf("Update GitHub issue #%v", issueNum)
log.Run(task)
client := ghutil.NewClient(config.Token())
newIssue, _, err := client.Issues.Edit(owner, repo, issueNum, &github.IssueRequest{
Body: github.String(bodyBuffer.String()),
State: github.String("open"),
})
if err != nil {
return errs.NewError(task, err)
}
// Add the review comment.
if err := addReviewComment(config, owner, repo, issueNum, addedCommits); err != nil {
return err
}
// Open the issue if requested.
if _, open := opts["open"]; open {
return openIssue(newIssue)
}
return nil
}
开发者ID:jkotrlik,项目名称:salsaflow,代码行数:60,代码来源:code_review_tool.go
示例3: CreateTrackingBranch
func CreateTrackingBranch(branch, remote string) error {
if err := Branch(branch, remote+"/"+branch); err != nil {
return err
}
log.Log(fmt.Sprintf("Local branch '%v' created (tracking %v/%v)", branch, remote, branch))
return nil
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:7,代码来源:git.go
示例4: InitialiseRelease
func (tool *codeReviewTool) InitialiseRelease(v *version.Version) (action.Action, error) {
// Get necessary config.
config, err := LoadConfig()
if err != nil {
return nil, err
}
owner, repo, err := git.ParseUpstreamURL()
if err != nil {
return nil, err
}
// Check whether the review milestone exists or not.
// People can create milestones manually, so this makes the thing more robust.
task := fmt.Sprintf("Check whether GitHub review milestone exists for release %v", v.BaseString())
log.Run(task)
milestone, err := milestoneForVersion(config, owner, repo, v)
if err != nil {
return nil, errs.NewError(task, err)
}
if milestone != nil {
// Milestone already exists, we are done.
log.Log(fmt.Sprintf("GitHub review milestone '%v' already exists", milestoneTitle(v)))
return nil, nil
}
// Create the review milestone.
_, act, err := createMilestone(config, owner, repo, v)
return act, err
}
开发者ID:jkotrlik,项目名称:salsaflow,代码行数:30,代码来源:code_review_tool.go
示例5: CheckOrCreateTrackingBranch
// CheckOrCreateTrackingBranch tries to make sure that a local branch
// of the given name exists and is in sync with the given remote.
//
// So, in case the right remote branch exists and the local does not,
// the local tracking branch is created. In case the local branch
// exists already, it is ensured that it is up to date.
func CheckOrCreateTrackingBranch(branch, remote string) error {
// Check whether the remote counterpart exists.
exists, err := RemoteBranchExists(branch, remote)
if err != nil {
return err
}
if !exists {
return &ErrRefNotFound{remote + "/" + branch}
}
// Check whether the local branch exists.
exists, err = LocalBranchExists(branch)
if err != nil {
return err
}
if !exists {
if err := Branch(branch, remote+"/"+branch); err != nil {
return err
}
log.Log(fmt.Sprintf("Local branch '%v' created (tracking %v/%v)", branch, remote, branch))
return nil
}
// In case it exists, make sure that it is up to date.
return EnsureBranchSynchronized(branch, remote)
}
开发者ID:jkotrlik,项目名称:salsaflow,代码行数:32,代码来源:git.go
示例6: PostReviewRequests
func (tool *codeReviewTool) PostReviewRequests(
ctxs []*common.ReviewContext,
opts map[string]interface{},
) error {
log.Log("NOOP code review module active, not doing anything")
return nil
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:7,代码来源:code_review_tool.go
示例7: createIssue
func createIssue(
task string,
config Config,
owner string,
repo string,
issueTitle string,
issueBody string,
milestone *github.Milestone,
) (issue *github.Issue, err error) {
log.Run(task)
client := ghutil.NewClient(config.Token())
labels := []string{config.ReviewLabel()}
issue, _, err = client.Issues.Create(owner, repo, &github.IssueRequest{
Title: github.String(issueTitle),
Body: github.String(issueBody),
Labels: &labels,
Milestone: milestone.Number,
})
if err != nil {
return nil, errs.NewError(task, err)
}
log.Log(fmt.Sprintf("GitHub issue #%v created", *issue.Number))
return issue, nil
}
开发者ID:jkotrlik,项目名称:salsaflow,代码行数:26,代码来源:code_review_tool.go
示例8: copyHook
// copyHook installs the SalsaFlow git hook by copying the hook executable
// from the expected absolute path to the git config hook directory.
func copyHook(hookType HookType, hookExecutable, hookDestPath string) error {
task := fmt.Sprintf("Install the SalsaFlow git %v hook", hookType)
if err := fileutil.CopyFile(hookExecutable, hookDestPath); err != nil {
return errs.NewError(task, err)
}
if err := os.Chmod(hookDestPath, 0750); err != nil {
return errs.NewError(task, err)
}
log.Log(fmt.Sprintf("SalsaFlow git %v hook installed", hookType))
return nil
}
开发者ID:jkotrlik,项目名称:salsaflow,代码行数:13,代码来源:check.go
示例9: tryToStageRunningRelease
func tryToStageRunningRelease() {
stagingTask := "Try to stage the next release for acceptance"
log.Run(stagingTask)
_, err := commands.Stage(&commands.StageOptions{
SkipFetch: true,
})
if err != nil {
// Not terribly pretty, but it works. We just handle the known errors and continue.
// It is ok when the release branch does not exist yet or the release cannot be staged
// in the issue tracker.
rootCause := errs.RootCause(err)
if ex, ok := rootCause.(*git.ErrRefNotFound); ok {
log.Log(fmt.Sprintf("Git reference '%v' not found, not staging any release", ex.Ref))
} else if rootCause == common.ErrNotStageable {
log.Log("The next release cannot be staged yet, staging canceled")
} else {
errs.LogError(stagingTask, err)
log.Log("Failed to stage the next release, continuing anyway ...")
}
}
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:21,代码来源:command.go
示例10: ensureStoryId
func ensureStoryId(commits []*git.Commit) ([]*git.Commit, bool, error) {
task := "Make sure the commits comply with the rules"
if i, missing := isStoryIdMissing(commits); missing {
commits, err := rewriteCommits(commits, i)
if err != nil {
return nil, false, errs.NewError(task, err)
}
return commits, true, nil
} else {
log.Log("Commit check passed")
return commits, false, nil
}
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:13,代码来源:common.go
示例11: run
func run(cmd *gocli.Command, args []string) {
if len(args) != 0 {
cmd.Usage()
os.Exit(2)
}
if err := app.Init(flagForce); err != nil {
if errs.RootCause(err) == repo.ErrInitialised {
log.Log("The repository has been already initialised")
return
}
errs.Fatal(err)
}
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:14,代码来源:command.go
示例12: run
func run(cmd *gocli.Command, args []string) {
if len(args) != 0 {
cmd.Usage()
os.Exit(2)
}
app.InitOrDie()
if err := pkg.Upgrade(&pkg.InstallOptions{flagOwner, flagRepo}); err != nil {
if err == pkg.ErrAborted {
fmt.Println("\nYour wish is my command, exiting now!")
return
}
errs.Fatal(err)
}
log.Log("SalsaFlow was upgraded successfully")
}
开发者ID:jkotrlik,项目名称:salsaflow,代码行数:18,代码来源:command.go
示例13: postCommitsForReview
func postCommitsForReview(commits []*git.Commit) error {
// Pick the commits to be posted for review.
if flagPick {
task := "Select the commits to be posted for review"
var err error
commits, err = selectCommitsForReview(commits)
if err != nil {
return errs.NewError(task, err)
}
if len(commits) == 0 {
log.NewLine("")
log.Log("No commits selected, aborting...")
prompt.PanicCancel()
}
}
// Print Snoopy.
asciiart.PrintSnoopy()
// Turn Commits into ReviewContexts.
task := "Fetch stories for the commits to be posted for review"
log.Run(task)
ctxs, err := commitsToReviewContexts(commits)
if err != nil {
return errs.NewError(task, err)
}
// Mark the stories as implemented, potentially.
task = "Mark the stories as implemented, optionally"
implemented, act, err := implementedDialog(ctxs)
if err != nil {
return errs.NewError(task, err)
}
defer action.RollbackTaskOnError(&err, task, act)
// Post the review requests.
task = "Post the review requests"
if err := sendReviewRequests(ctxs, implemented); err != nil {
return errs.NewError(task, err)
}
return nil
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:44,代码来源:common.go
示例14: createIssue
func createIssue(
task string,
config *moduleConfig,
owner string,
repo string,
issueTitle string,
issueBody string,
assignee string,
milestone *github.Milestone,
implemented bool,
) (issue *github.Issue, err error) {
log.Run(task)
client := ghutil.NewClient(config.Token)
var labels []string
if implemented {
labels = []string{config.ReviewLabel, config.StoryImplementedLabel}
} else {
labels = []string{config.ReviewLabel}
}
var assigneePtr *string
if assignee != "" {
assigneePtr = &assignee
}
issue, _, err = client.Issues.Create(owner, repo, &github.IssueRequest{
Title: github.String(issueTitle),
Body: github.String(issueBody),
Labels: &labels,
Assignee: assigneePtr,
Milestone: milestone.Number,
})
if err != nil {
return nil, errs.NewError(task, err)
}
log.Log(fmt.Sprintf("GitHub issue #%v created", *issue.Number))
return issue, nil
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:41,代码来源:code_review_tool.go
示例15: runMain
func runMain(cmd *gocli.Command) (err error) {
// Validate CL flags.
task := "Check the command line flags"
switch {
case flagSkeleton == "" && !flagNoSkeleton:
cmd.Usage()
return errs.NewError(
task, errors.New("-no_skeleton must be specified when no skeleton is given"))
case flagSkeletonOnly && flagSkeleton == "":
cmd.Usage()
return errs.NewError(
task, errors.New("-skeleton must be specified when -skeleton_only is set"))
}
// Make sure the local config directory exists.
act, err := ensureLocalConfigDirectoryExists()
if err != nil {
return err
}
defer action.RollbackOnError(&err, act)
// Set up the global and local configuration file unless -skeleton_only.
if !flagSkeletonOnly {
if err := assembleAndWriteConfig(); err != nil {
return err
}
}
// Install the skeleton into the local config directory if desired.
if skeleton := flagSkeleton; skeleton != "" {
if err := getAndPourSkeleton(skeleton); err != nil {
return err
}
}
fmt.Println()
log.Log("Successfully bootstrapped the repository for SalsaFlow")
log.NewLine("Do not forget to commit modified configuration files!")
return nil
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:41,代码来源:command.go
示例16: GetOrCreateMilestoneForTitle
func GetOrCreateMilestoneForTitle(
client *github.Client,
owner string,
repo string,
title string,
) (*github.Milestone, action.Action, error) {
// Try to get the milestone.
milestone, err := FindMilestoneByTitle(client, owner, repo, title)
if err != nil {
return nil, nil, err
}
if milestone != nil {
// Milestone found, return it.
log.Log(fmt.Sprintf("GitHub milestone '%v' already exists", title))
return milestone, nil, nil
}
// Create the milestone when not found.
return CreateMilestone(client, owner, repo, title)
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:21,代码来源:milestones.go
示例17: push
func push(remote, branch string) error {
task := fmt.Sprintf("Push branch '%v' to remote '%v'", branch, remote)
msg := fmt.Sprintf("Pushing branch '%v' to synchronize", branch)
isCore, err := git.IsCoreBranch(branch)
if err != nil {
return errs.NewError(task, err)
}
if !isCore {
msg += " (using force)"
}
log.Log(msg)
if isCore {
err = git.Push(remote, branch)
} else {
err = git.PushForce(remote, branch)
}
if err != nil {
return errs.NewError(task, err)
}
return nil
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:24,代码来源:common.go
示例18: runMain
//.........这里部分代码省略.........
defer action.RollbackTaskOnError(&err, task, act)
// Bump version for the stable branch.
stableVersion, err := stagingVersion.ToStableVersion()
if err != nil {
return err
}
task = fmt.Sprintf("Bump version (branch '%v' -> %v)", stableBranch, stableVersion)
log.Run(task)
act, err = version.SetForBranch(stableVersion, stableBranch)
if err != nil {
return errs.NewError(task, err)
}
defer action.RollbackTaskOnError(&err, task, act)
// Tag the stable branch.
tag := stableVersion.ReleaseTagString()
task = fmt.Sprintf("Tag branch '%v' with tag '%v'", stableBranch, tag)
log.Run(task)
if err := git.Tag(tag, stableBranch); err != nil {
return errs.NewError(task, err)
}
defer action.RollbackTaskOnError(&err, task, action.ActionFunc(func() error {
task := fmt.Sprintf("Delete tag '%v'", tag)
if err := git.Tag("-d", tag); err != nil {
return errs.NewError(task, err)
}
return nil
}))
// Generate the release notes.
// We try to do as much as possible before pushing.
task = fmt.Sprintf("Generate release notes for version '%v'", stableVersion)
log.Run(task)
rnm, err := modules.GetReleaseNotesManager()
if err != nil {
if _, ok := err.(*modules.ErrModuleNotSet); !ok {
return errs.NewError(task, err)
}
}
var nts *common.ReleaseNotes
// rnm will be nil in case the module is disabled.
if rnm != nil {
// Get the relevant stories.
stories, err := tracker.ListStoriesByRelease(stableVersion)
if err != nil {
return errs.NewError(task, err)
}
// Generate the release notes.
nts = notes.GenerateReleaseNotes(stableVersion, stories)
} else {
log.Log("Release notes module disabled, not doing anything")
}
// Close the release in the issue tracker.
act, err = issueTrackerRelease.Close()
if err != nil {
return err
}
defer action.RollbackOnError(&err, act)
// Close the release in the code review tool.
act, err = codeReviewRelease.Close()
if err != nil {
return err
}
defer action.RollbackOnError(&err, act)
// Push the changes to the remote repository.
task = "Push changes to the remote repository"
log.Run(task)
toPush := []string{
"--tags",
fmt.Sprintf("%v:%v", stableBranch, stableBranch),
}
if err := git.PushForce(remoteName, toPush...); err != nil {
return errs.NewError(task, err)
}
// Post the release notes.
task = fmt.Sprintf("Post the release notes for version '%v'", stableVersion)
if rnm != nil {
log.Run(task)
if _, err := rnm.PostReleaseNotes(nts); err != nil {
errs.LogError(task, err)
log.Warn("Failed to post the release notes, continuing anyway ...")
}
}
// Tell the user we succeeded.
color.Green("\n-----> Release %v deployed successfully!\n\n", stableVersion)
color.Cyan("Let's check whether the next release branch can be staged already.\n")
color.Cyan("In other words, we will try to run `release stage` and see what happens.\n\n")
// Now we proceed to the staging step. We do not roll back
// the previous changes on error since this is a separate step.
tryToStageRunningRelease()
return nil
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:101,代码来源:command.go
示例19: EnsureBranchSynchronized
// EnsureBranchSynchronized makes sure the given branch is up to date.
// If that is not the case, *ErrRefNoInSync is returned.
func EnsureBranchSynchronized(branch, remote string) (err error) {
// Check whether the remote counterpart actually exists.
exists, err := RemoteBranchExists(branch, remote)
if err != nil {
return err
}
if !exists {
return nil
}
// Get the data needed.
var (
localRef = fmt.Sprintf("refs/heads/%v", branch)
remoteRef = fmt.Sprintf("refs/remotes/%v/%v", remote, branch)
)
localHexsha, err := Hexsha(localRef)
if err != nil {
return err
}
remoteHexsha, err := Hexsha(remoteRef)
if err != nil {
return err
}
if localHexsha == remoteHexsha {
// The branch is up to date, we are done here.
return nil
}
// Check whether the local branch can be fast-forwarded.
remoteBranch := fmt.Sprintf("%v/%v", remote, branch)
_, err = Run("merge-base", "--is-ancestor", branch, remoteBranch)
if err != nil {
// --is-ancestor returns exit status 0 on true, 1 on false, some other on error.
// We cannot check the value in a platform-independent way, but we count on the fact that
// stderr will be non-empty on error.
ex, ok := err.(errs.Err)
if !ok || len(ex.Hint()) != 0 {
// In case err is not implementing errs.Err or len(stderr) != 0, we return the error.
return err
}
// Otherwise the error means that --is-ancestor returned false,
// so we cannot fast-forward and we have to return an error.
return &ErrRefNotInSync{branch}
}
// Perform a fast-forward merge.
// Ask the user before doing so.
fmt.Println()
fmt.Printf("Branch '%v' is behind '%v', and can be fast-forwarded.\n", branch, remoteBranch)
proceed, err := prompt.Confirm("Shall we perform the merge? It's all safe!", true)
fmt.Println()
if err != nil {
return err
}
if !proceed {
return &ErrRefNotInSync{branch}
}
// Make sure the right branch is checked out.
currentBranch, err := gitutil.CurrentBranch()
if err != nil {
return err
}
if branch != currentBranch {
// Checkout the branch to be merged.
task := fmt.Sprintf("Checkout branch '%v'", branch)
if err := Checkout(branch); err != nil {
return errs.NewError(task, err)
}
defer func() {
// Checkout the original branch on return.
task := fmt.Sprintf("Checkout branch '%v'", currentBranch)
if ex := Checkout(currentBranch); ex != nil {
if err == nil {
err = ex
} else {
errs.LogError(task, err)
}
}
}()
}
// Merge. Use --ff-only, just to be sure.
// But we have already checked that this will be a fast-forward merge.
_, err = Run("merge", "--ff-only", remoteBranch)
if err != nil {
return err
}
log.Log(fmt.Sprintf("Branch '%v' fast-forwarded onto '%v'", branch, remoteBranch))
return nil
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:94,代码来源:git.go
示例20: load
func load(args *loadArgs) error {
// Save the args into regular variables.
var (
configKind = args.configKind
configKey = args.configKey
container = args.configContainer
readConfig = args.readConfig
emptyConfig = args.emptyConfig
disallowPrompt = args.disallowPrompt
)
// Do nothing in case the container is nil.
if container == nil {
return nil
}
// Read the configuration file.
configFile, err := readConfig()
if err != nil {
if emptyConfig == nil || !os.IsNotExist(errs.RootCause(err)) {
return err
}
// In case the file is not there, initialise a new one.
configFile = emptyConfig()
}
prompt := func(err error) error {
if disallowPrompt {
dialogTask := "Prompt the user for configuration according to the spec"
dialogErr := errors.New("configuration dialog is disabled")
dialogHint := `
The configuration dialog for the local configuration file can only be run
during 'repo bootstrap' so that the configuration file is not modified
without anybody noticing in the middle of other work being done.
Please fix the issues manually, either by manually editing the local
configuration file or by re-running 'repo bootstrap' command.
Don't forget to commit the changes.
`
if ex, ok := err.(errs.Err); ok {
err := errs.NewErrorWithHint(dialogTask, dialogErr, dialogHint)
return errs.NewErrorWithHint(ex.Task(), err, ex.Hint())
}
return errs.NewErrorWithHint(dialogTask, err, dialogHint)
}
return promptAndWrite(configFile, args)
}
// Find the config record for the given key.
// In case there is an error and the prompt is allowed, prompt the user.
section, err := configFile.ConfigRecord(configKey)
if err != nil {
return prompt(err)
}
// Unmarshal the record according to the spec.
// In case there is an error and the prompt is allowed, prompt the user.
if err := unmarshal(section.RawConfig, container); err != nil {
fmt.Println()
log.Log(fmt.Sprintf(
"Failed to unmarshal %v configuration, will try to run the bootstrap dialog",
configKind))
log.NewLine(fmt.Sprintf("(err = %v)", err.Error()))
return prompt(err)
}
// Validate the returned object according to the spec.
// In case there is an error and the prompt is allowed, prompt the user.
if err := validate(container, section.Path()); err != nil {
fmt.Println()
log.Log(fmt.Sprintf(
"%v configuration section invalid, will try to run the bootstrap dialog",
strings.Title(configKind)))
log.NewLine(fmt.Sprintf("(error = %v)", err.Error()))
return prompt(err)
}
return nil
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:81,代码来源:loader.go
注:本文中的github.com/salsaflow/salsaflow/log.Log函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论