<commit_before>package main

import (
	"context"
	"errors"
	"fmt"
	"io"
	"time"

	"github.com/weaveworks/flux/api"
	"github.com/weaveworks/flux/job"
	"github.com/weaveworks/flux/update"
)

var ErrTimeout = errors.New("timeout")

// await polls for a job to complete, then for the resulting commit to
// be applied
func await(ctx context.Context, stdout, stderr io.Writer, client api.Server, jobID job.ID, apply bool, verbosity int) error {
	result, err := awaitJob(ctx, client, jobID)
	if err != nil {
		return err
	}
	if result.Result != nil {
		update.PrintResults(stdout, result.Result, verbosity)
	}
	if result.Revision != "" {
		fmt.Fprintf(stderr, "Commit pushed:\t%s\n", result.Revision[:7])
	}
	if result.Result == nil {
		fmt.Fprintf(stderr, "Nothing to do\n")<commit_msg>Print advice and exit(0) on job result timeout<commit_after>package main

import (
	"context"
	"errors"
	"fmt"
	"io"
	"time"

	"github.com/weaveworks/flux/api"
	"github.com/weaveworks/flux/job"
	"github.com/weaveworks/flux/update"
)

var ErrTimeout = errors.New("timeout")

// await polls for a job to complete, then for the resulting commit to
// be applied
func await(ctx context.Context, stdout, stderr io.Writer, client api.Server, jobID job.ID, apply bool, verbosity int) error {
	result, err := awaitJob(ctx, client, jobID)
	if err != nil {
		if err == ErrTimeout {
			fmt.Fprintln(stderr, `
We timed out waiting for the result of the operation. This does not
necessarily mean it has failed. You can check the state of the
cluster, or commit logs, to see if there was a result. In general, it
is safe to retry operations.`)
			// because the outcome is unknown, still return the err to indicate an exceptional exit
		}
		return err
	}
	if result.Result != nil {
		update.PrintResults(stdout, result.Result, verbosity)
	}
	if result.Revision != "" {
		fmt.Fprintf(stderr, "Commit pushed:\t%s\n", result.Revision[:7])
	}
	if result.Result == nil {
		fmt.Fprintf(stderr, "Nothing to do\n")
{'fraction_non_alphanumeric': 0.12468322351748606, 'fraction_numerical': 0.0015205271160669033, 'mean_word_length': 4.01015228426396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '877520', 'n_tokens_mistral': 690, 'n_tokens_neox': 661, 'n_words': 214}