本文整理汇总了Golang中github.com/salsaflow/salsaflow/log.Log函数的典型用法代码示例。如果您正苦于以下问题:Golang Log函数的具体用法?Golang Log怎么用?Golang Log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
}
}
示例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
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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
}
示例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 ...")
}
}
}
示例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
}
}
示例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)
}
}
示例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")
}
示例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
}
示例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
}
示例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
}