id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c175800 | "/")
if len(parts) != 2 { // TODO(fejta): use a strong type here instead
p.errors.add(fmt.Errorf("bad presubmit repo: %s", repo))
continue
}
orgName := parts[0]
repoName := parts[1]
repo := bp.GetOrg(orgName).GetRepo(repoName)
if err := p.UpdateRepo(orgName, repoName, *repo); err != nil {
p.errors.add(fmt.Errorf("update %s/%s: %v", orgName, repoName, err))
}
}
} | |
c175801 | {
// Unopinionated org, just set explicitly defined repos
for r := range org.Repos {
repos = append(repos, r)
}
}
for _, repoName := range repos {
repo := org.GetRepo(repoName)
if err := p.UpdateRepo(orgName, repoName, *repo); err != nil {
return fmt.Errorf("update %s: %v", repoName, err)
}
}
return nil
} | |
c175802 | put true second so b.Protected is set correctly
bs, err := p.client.GetBranches(orgName, repoName, onlyProtected)
if err != nil {
return fmt.Errorf("list branches: %v", err)
}
for _, b := range bs {
branches[b.Name] = b
}
}
for bn, githubBranch := range branches {
if branch, err := repo.GetBranch(bn); err != nil {
return fmt.Errorf("get %s: %v", bn, err)
} else if err = p.UpdateBranch(orgName, repoName, bn, *branch, githubBranch.Protected); err != nil {
return fmt.Errorf("update %s from protected=%t: %v", bn, githubBranch.Protected, err)
}
}
return nil
} | |
c175803 | == nil {
return nil
}
if !protected && !*bp.Protect {
logrus.Infof("%s/%s=%s: already unprotected", orgName, repo, branchName)
return nil
}
var req *github.BranchProtectionRequest
if *bp.Protect {
r := makeRequest(*bp)
req = &r
}
p.updates <- requirements{
Org: orgName,
Repo: repo,
Branch: branchName,
Request: req,
}
return nil
} | |
c175804 | json.Unmarshal([]byte(config), o)
} | |
c175805 | nil {
return err
}
controller := artifact_uploader.NewController(client.CoreV1(), prowJobClient, o.Options)
stop := make(chan struct{})
defer close(stop)
go controller.Run(o.NumWorkers, stop)
// Wait forever
select {}
} | |
c175806 | secretsMap
// Start one goroutine for each file to monitor and update the secret's values.
for secretPath := range secretsMap {
go a.reloadSecret(secretPath)
}
return nil
} | |
c175807 | skips++
continue // file hasn't been modified
}
lastModTime = recentModTime
}
if secretValue, err := LoadSingleSecret(secretPath); err != nil {
logger.WithField("secret-path: ", secretPath).
WithError(err).Error("Error loading secret.")
} else {
a.setSecret(secretPath, secretValue)
skips = 0
}
}
} | |
c175808 | defer a.RUnlock()
return a.secretsMap[secretPath]
} | |
c175809 | []byte) {
a.Lock()
defer a.Unlock()
a.secretsMap[secretPath] = secretValue
} | |
c175810 | func() []byte {
return func() []byte {
return a.GetSecret(secretPath)
}
} | |
c175811 | }
logrus.WithFields(logrus.Fields{
"duration": time.Since(start).String(),
"path": hist.path,
}).Debugf("Successfully read action history for %d pools.", len(hist.logs))
}
return hist, nil
} | |
c175812 | Action: action,
BaseSHA: baseSHA,
Target: targets,
Err: err,
},
)
} | |
c175813 | w.Write(b); err != nil {
logrus.WithError(err).Error("Writing JSON history response.")
}
} | |
c175814 | nil {
log.WithError(err).Error("Error flushing action history to GCS.")
} else {
log.Debugf("Successfully flushed action history for %d pools.", len(h.logs))
}
} | |
c175815 | := range h.logs {
res[key] = log.toSlice()
}
return res
} | |
c175816 | gcs directory.`,
Run: func(cmd *cobra.Command, args []string) {
run(flags, cmd, args)
},
}
cmd.Flags().StringVarP(&flags.outputFile, "output", "o", "-", "output file")
cmd.Flags().StringVarP(&flags.artifactsDirName, "artifactsDir", "a", "artifacts", "artifact directory name in GCS")
cmd.Flags().StringVarP(&flags.profileName, "profile", "p", "coverage-profile", "code coverage profile file name in GCS")
return cmd
} | |
c175817 | matcher, err := regexp.Compile(pattern)
if err != nil {
return err
}
c.matcher = append(c.matcher, matcher)
}
return nil
} | |
c175818 | if matcher.MatchString(comment.Body) {
points = append(points, Point{
Values: map[string]interface{}{
"comment": 1,
},
Date: comment.CommentCreatedAt,
})
}
}
return points
} | |
c175819 | queue,
informer: informer,
reporter: reporter,
numWorkers: numWorkers,
wg: wg,
}
} | |
c175820 | c.informer.Informer().Run(stopCh)
// do the initial synchronization (one time) to populate resources
if !cache.WaitForCacheSync(stopCh, c.HasSynced) {
utilruntime.HandleError(fmt.Errorf("Error syncing cache"))
return
}
logrus.Info("Controller.Run: cache sync complete")
// run the runWorker method every second with a stop channel
for i := 0; i < c.numWorkers; i++ {
go wait.Until(c.runWorker, time.Second, stopCh)
}
logrus.Infof("Started %d workers", c.numWorkers)
<-stopCh
logrus.Info("Shutting down workers")
} | |
c175821 | c.processNextItem() {
}
c.wg.Done()
} | |
c175822 | nil, nil, err
}
c, err := git.NewClient()
if err != nil {
os.RemoveAll(t)
return nil, nil, err
}
getSecret := func() []byte {
return []byte("")
}
c.SetCredentials("", getSecret)
c.SetRemote(t)
return &LocalGit{
Dir: t,
Git: g,
}, c, nil
} | |
c175823 | err := runCmd(lg.Git, rdir, "config", "commit.gpgsign", "false"); err != nil {
return err
}
if err := lg.AddCommit(org, repo, map[string][]byte{"initial": {}}); err != nil {
return err
}
return nil
} | |
c175824 | := ioutil.WriteFile(path, b, os.ModePerm); err != nil {
return err
}
if err := runCmd(lg.Git, rdir, "add", f); err != nil {
return err
}
}
return runCmd(lg.Git, rdir, "commit", "-m", "wow")
} | |
c175825 | {
rdir := filepath.Join(lg.Dir, org, repo)
return runCmd(lg.Git, rdir, "checkout", "-b", branch)
} | |
c175826 |
rdir := filepath.Join(lg.Dir, org, repo)
return runCmd(lg.Git, rdir, "checkout", commitlike)
} | |
c175827 | {
rdir := filepath.Join(lg.Dir, org, repo)
return runCmdOutput(lg.Git, rdir, "rev-parse", commitlike)
} | |
c175828 | "Couldn't sweep resources of type %T", typ)
}
}
}
for _, typ := range GlobalTypeList {
set, err := typ.ListAll(sess, acct, regions.Default)
if err != nil {
return errors.Wrapf(err, "Failed to list resources of type %T", typ)
}
if err := typ.MarkAndSweep(sess, acct, regions.Default, set); err != nil {
return errors.Wrapf(err, "Couldn't sweep resources of type %T", typ)
}
}
return nil
} | |
c175829 | if !strInSlice(org, config.Lgtm[i].Repos) && !strInSlice(fullName, config.Lgtm[i].Repos) {
continue
}
return &config.Lgtm[i]
}
return &plugins.Lgtm{}
} | |
c175830 |
var filenames []string
for _, change := range changes {
filenames = append(filenames, change.Filename)
}
return filenames, nil
} | |
c175831 | reviewers = reviewers.Union(ro.Approvers(filename)).Union(ro.Reviewers(filename))
}
return reviewers
} | |
c175832 | lastSyncFallback: %v", err)
} else {
logrus.Warnf("lastSyncFallback not found: %s", lastSyncFallback)
lastUpdate = time.Now()
}
c, err := client.NewClient(projects)
if err != nil {
return nil, err
}
c.Start(cookiefilePath)
return &Controller{
kc: kc,
config: cfg,
gc: c,
lastUpdate: lastUpdate,
lastSyncFallback: lastSyncFallback,
}, nil
} | |
c175833 |
err = os.Rename(tempFile.Name(), c.lastSyncFallback)
if err != nil {
logrus.WithError(err).Info("Rename failed, fallback to copyfile")
return copyFile(tempFile.Name(), c.lastSyncFallback)
}
return nil
} | |
c175834 | %s", len(changes), instance)
}
c.lastUpdate = syncTime
if err := c.SaveLastSync(syncTime); err != nil {
logrus.WithError(err).Errorf("last sync %v, cannot save to path %v", syncTime, c.lastSyncFallback)
}
return nil
} | |
c175835 | {
cmd.Flags().StringVar(&e.desc, "event", "", "Match event (eg: `opened`)")
} | |
c175836 | = NewEventMatcher(e.desc)
return nil
} | |
c175837 | []Point{
{
Values: map[string]interface{}{"event": 1},
Date: event.EventCreatedAt,
},
}
} | |
c175838 | }
logrus.WithField("dest", name).Info("Finished upload")
}(upload, obj, dest)
}
group.Wait()
close(errCh)
if len(errCh) != 0 {
var uploadErrors []error
for err := range errCh {
uploadErrors = append(uploadErrors, err)
}
return fmt.Errorf("encountered errors during upload: %v", uploadErrors)
}
return nil
} | |
c175839 |
uploadErr := DataUploadWithMetadata(reader, metadata)(obj)
closeErr := reader.Close()
return errorutil.NewAggregate(uploadErr, closeErr)
}
} | |
c175840 |
_, copyErr := io.Copy(writer, src)
closeErr := writer.Close()
return errorutil.NewAggregate(copyErr, closeErr)
}
} | |
c175841 | issueLabels {
if strings.ToLower(l.Name) == strings.ToLower(label) {
return true
}
}
return false
} | |
c175842 |
return true, fmt.Errorf("failing %d response", sc)
}
size, _ := strconv.Atoi(resp.Header.Get("Content-Length"))
if size > limit {
return true, nil
}
return false, nil
} | |
c175843 |
return Admin
} else if permissions.Push {
return Write
} else if permissions.Pull {
return Read
} else {
return None
}
} | |
c175844 | return RepoPermissions{Pull: true}
case Write:
return RepoPermissions{Pull: true, Push: true}
case Admin:
return RepoPermissions{Pull: true, Push: true, Admin: true}
default:
return RepoPermissions{}
}
} | |
c175845 | {
return &prowJobs{
client: c.RESTClient(),
ns: namespace,
}
} | |
c175846 | repo, branch: branch}]...)
sort.Slice(res, func(i, j int) bool {
return res[i].Number < res[j].Number
})
return res
} | |
c175847 | logrus.WithError(http.ListenAndServe(":8080", nil)).Fatal("ListenAndServe returned.")
} | |
c175848 | := NewAuthorFilterPluginWrapper(typeFilter)
cmd := &cobra.Command{
Use: "count",
Short: "Count events and number of issues in given state, and for how long",
RunE: func(cmd *cobra.Command, args []string) error {
if err := eventCounter.CheckFlags(); err != nil {
return err
}
if err := stateCounter.CheckFlags(); err != nil {
return err
}
if err := typeFilter.CheckFlags(); err != nil {
return err
}
if err := commentCounter.CheckFlags(); err != nil {
return err
}
return runner(authorFilter)
},
}
eventCounter.AddFlags(cmd)
stateCounter.AddFlags(cmd)
commentCounter.AddFlags(cmd)
typeFilter.AddFlags(cmd)
authorFilter.AddFlags(cmd)
authorLogged.AddFlags(cmd)
return cmd
} | |
c175849 | IssueID: comment.IssueID,
Event: "commented",
EventCreatedAt: comment.CommentCreatedAt,
Actor: &comment.User,
}
return append(
o.plugin.ReceiveComment(comment),
o.plugin.ReceiveIssueEvent(fakeEvent)...,
)
} | |
c175850 | metrics")
} else {
promMetrics.DiskFree.Set(float64(bytesFree) / 1e9)
promMetrics.DiskUsed.Set(float64(bytesUsed) / 1e9)
promMetrics.DiskTotal.Set(float64(bytesFree+bytesUsed) / 1e9)
}
}
} | |
c175851 | logrus.WithError(err).Errorf("Fail to marshal Resources. %v", resources)
}
logrus.Infof("Current Resources : %v", string(resJSON))
} | |
c175852 | if err != nil {
return err
}
if err := r.Storage.SyncResources(resources); err != nil {
return err
}
return nil
} | |
c175853 | metric.Current[res.State] = 0
}
if _, ok := metric.Owners[res.Owner]; !ok {
metric.Owners[res.Owner] = 0
}
metric.Current[res.State]++
metric.Owners[res.Owner]++
}
if len(metric.Current) == 0 && len(metric.Owners) == 0 {
return metric, &ResourceNotFound{rtype}
}
return metric, nil
} | |
c175854 | return "", fmt.Errorf("invalid url %s: %v", dogURL, err)
}
return fmt.Sprintf("[](%s)", src, src), nil
} | |
c175855 | err
}
runErr := RunRequested(c, pr, requestedJobs, eventGUID)
var skipErr error
if !elideSkippedContexts {
skipErr = skipRequested(c, pr, skippedJobs)
}
return errorutil.NewAggregate(runErr, skipErr)
} | |
c175856 | for _, job := range toSkip {
skippedContexts.Insert(job.Context)
}
if overlap := requestedContexts.Intersection(skippedContexts).List(); len(overlap) > 0 {
return fmt.Errorf("the following contexts are both triggered and skipped: %s", strings.Join(overlap, ", "))
}
return nil
} | |
c175857 | eventGUID)
c.Logger.WithFields(pjutil.ProwJobFields(&pj)).Info("Creating a new prowjob.")
if _, err := c.ProwJobClient.Create(&pj); err != nil {
c.Logger.WithError(err).Error("Failed to create prowjob.")
errors = append(errors, err)
}
}
return errorutil.NewAggregate(errors...)
} | |
c175858 | err := c.GitHubClient.CreateStatus(pr.Base.Repo.Owner.Login, pr.Base.Repo.Name, pr.Head.SHA, skippedStatusFor(job.Context)); err != nil {
errors = append(errors, err)
}
}
return errorutil.NewAggregate(errors...)
} | |
c175859 | eventName == "labeled" && label == l.Label
} | |
c175860 | eventName == "unlabeled" && label == u.Label
} | |
c175861 | *flag.FlagSet) {
o.addFlags(true, fs)
} | |
c175862 | *flag.FlagSet) {
o.addFlags(false, fs)
} | |
c175863 | else if _, err := url.Parse(o.graphqlEndpoint); err != nil {
return fmt.Errorf("invalid -github-graphql-endpoint URI: %q", o.graphqlEndpoint)
}
if o.deprecatedTokenFile != "" {
o.TokenPath = o.deprecatedTokenFile
logrus.Error("-github-token-file is deprecated and may be removed anytime after 2019-01-01. Use -github-token-path instead.")
}
if o.TokenPath == "" {
logrus.Warn("empty -github-token-path, will use anonymous github client")
}
return nil
} | |
c175864 | }
if dryRun {
return github.NewDryRunClientWithFields(fields, *generator, o.graphqlEndpoint, o.endpoint.Strings()...), nil
}
return github.NewClientWithFields(fields, *generator, o.graphqlEndpoint, o.endpoint.Strings()...), nil
} | |
c175865 | (client *github.Client, err error) {
return o.GitHubClientWithLogFields(secretAgent, dryRun, logrus.Fields{})
} | |
c175866 | Git client.
githubClient, err := o.GitHubClient(secretAgent, dryRun)
if err != nil {
return nil, fmt.Errorf("error getting GitHub client: %v", err)
}
botName, err := githubClient.BotName()
if err != nil {
return nil, fmt.Errorf("error getting bot name: %v", err)
}
client.SetCredentials(botName, secretAgent.GetTokenGenerator(o.TokenPath))
return client, nil
} | |
c175867 |
m := make(map[string]calculation.Coverage)
for _, cov := range g.Group {
m[cov.Name] = cov
}
return m
} | |
c175868 | if isChangeSignificant(baseRatio, newRatio) {
changes = append(changes, &coverageChange{
name: newCov.Name,
baseRatio: baseRatio,
newRatio: newRatio,
})
}
}
return changes
} | |
c175869 | db.AutoMigrate(&Assignee{}, &Issue{}, &IssueEvent{}, &Label{}, &Comment{}).Error
if err != nil {
return nil, err
}
return db, nil
} | |
c175870 | false
}
if c.reportAgent != "" && pj.Spec.Agent != c.reportAgent {
// Only report for specified agent
return false
}
return true
} | |
c175871 | c.config().Plank.ReportTemplate, *pj, c.config().GitHubReporter.JobTypesToReport)
} | |
c175872 |
}
if len(s.swept) > 0 {
klog.Errorf("%d resources swept: %v", len(s.swept), s.swept)
}
return len(s.swept)
} | |
c175873 | cfg config.Getter) *JobAgent {
return &JobAgent{
kc: kc,
pkcs: plClients,
config: cfg,
}
} | |
c175874 | range t {
ja.tryUpdate()
}
}()
} | |
c175875 | make([]Job, len(ja.jobs))
copy(res, ja.jobs)
return res
} | |
c175876 | make([]prowapi.ProwJob, len(ja.prowJobs))
copy(res, ja.prowJobs)
return res
} | |
c175877 | if ok {
j, ok = idMap[id]
}
ja.mut.Unlock()
if !ok {
return prowapi.ProwJob{}, errProwjobNotFound
}
return j, nil
} | |
c175878 | }
var b bytes.Buffer
if err := agentToTmpl.URLTemplate.Execute(&b, &j); err != nil {
return nil, fmt.Errorf("cannot execute URL template for prowjob %q with agent %q: %v", j.ObjectMeta.Name, j.Spec.Agent, err)
}
resp, err := http.Get(b.String())
if err != nil {
return nil, err
}
defer resp.Body.Close()
return ioutil.ReadAll(resp.Body)
}
return nil, fmt.Errorf("cannot get logs for prowjob %q with agent %q: the agent is missing from the prow config file", j.ObjectMeta.Name, j.Spec.Agent)
} | |
c175879 | sets.NewString(parent...)
s.Insert(child...)
return s.List()
} | |
c175880 | mergeRestrictions(p.Restrictions, child.Restrictions),
RequiredPullRequestReviews: mergeReviewPolicy(p.RequiredPullRequestReviews, child.RequiredPullRequestReviews),
}
} | |
c175881 |
if ok {
o.Policy = bp.Apply(o.Policy)
} else {
o.Policy = bp.Policy
}
return &o
} | |
c175882 |
} else {
r.Policy = o.Policy
}
return &r
} | |
c175883 | return nil, errors.New("defined branch policies must set protect")
}
} else {
b.Policy = r.Policy
}
return &b, nil
} | |
c175884 | old
switch {
case policy.defined() && c.BranchProtection.AllowDisabledPolicies:
logrus.Warnf("%s/%s=%s defines a policy but has protect: false", org, repo, branch)
policy = Policy{
Protect: policy.Protect,
}
case policy.defined():
return nil, fmt.Errorf("%s/%s=%s defines a policy, which requires protect: true", org, repo, branch)
}
policy.Protect = old
}
if !policy.defined() {
return nil, nil
}
return &policy, nil
} | |
c175885 |
for event := range c {
eventOrm, err := NewIssueEvent(event, issueID, client.RepositoryName())
if err != nil {
glog.Error("Failed to create issue-event", err)
}
db.Create(eventOrm)
}
} | |
c175886 | o.Spec.Namespace, o.Name))
case *buildv1alpha1.Build:
c.workqueue.AddRateLimited(toKey(ctx, o.Namespace, o.Name))
default:
logrus.Warnf("cannot enqueue unknown type %T: %v", o, obj)
return
}
} | |
c175887 | description(cond, descFailed)
case started.IsZero():
return prowjobv1.TriggeredState, description(cond, descInitializing)
case cond.Status == coreapi.ConditionUnknown, finished.IsZero():
return prowjobv1.PendingState, description(cond, descRunning)
}
logrus.Warnf("Unknown condition %#v", cond)
return prowjobv1.ErrorState, description(cond, descUnknown) // shouldn't happen
} | |
c175888 | downwardapi.EnvForSpec(downwardapi.NewJobSpec(pj.Spec, buildID, pj.Name))
} | |
c175889 | }
for _, k := range sets.StringKeySet(rawEnv).List() { // deterministic ordering
if keys.Has(k) {
continue
}
t.Arguments = append(t.Arguments, buildv1alpha1.ArgumentSpec{Name: k, Value: rawEnv[k]})
}
} | |
c175890 | }
for _, k := range sets.StringKeySet(rawEnv).List() { // deterministic ordering
if keys.Has(k) {
continue
}
c.Env = append(c.Env, coreapi.EnvVar{Name: k, Value: rawEnv[k]})
}
} | |
c175891 | i := range b.Spec.Steps {
if b.Spec.Steps[i].WorkingDir != "" {
continue
}
b.Spec.Steps[i].WorkingDir = wd.Value
}
if b.Spec.Template != nil {
// Best we can do for a template is to set WORKDIR
b.Spec.Template.Arguments = append(b.Spec.Template.Arguments, wd)
}
return true, nil
} | |
c175892 |
initUpload, err := decorate.InitUpload(dc.UtilityImages.InitUpload, gcsOptions, gcsMount, cloneLogMount, encodedJobSpec)
if err != nil {
return nil, nil, nil, fmt.Errorf("inject initupload: %v", err)
}
placer := decorate.PlaceEntrypoint(dc.UtilityImages.Entrypoint, toolsMount)
return []coreapi.Container{placer, *initUpload}, sidecar, &gcsVol, nil
} | |
c175893 | && dc.Timeout.Duration > 0:
return dc.Timeout.Duration
default:
return defaultTimeout
}
} | |
c175894 | return nil, fmt.Errorf("inject source: %v", err)
}
injectTimeout(&b.Spec, pj.Spec.DecorationConfig, defaultTimeout)
if pj.Spec.DecorationConfig != nil {
encodedJobSpec := rawEnv[downwardapi.JobSpecEnv]
err = decorateBuild(&b.Spec, encodedJobSpec, *pj.Spec.DecorationConfig, injectedSource)
if err != nil {
return nil, fmt.Errorf("decorate build: %v", err)
}
}
return &b, nil
} | |
c175895 | name field")
}
labels = append(labels, sql.Label{
IssueID: strconv.Itoa(issueID),
Name: *label.Name,
Repository: repository,
})
}
return labels, nil
} | |
c175896 | fmt.Errorf("Assignee is missing Login field")
}
assignees = append(assignees, sql.Assignee{
IssueID: strconv.Itoa(issueID),
Name: *assignee.Login,
Repository: repository,
})
}
return assignees, nil
} | |
c175897 | itoa(*gComment.ID),
IssueID: strconv.Itoa(issueID),
Body: *gComment.Body,
User: login,
CommentCreatedAt: *gComment.CreatedAt,
CommentUpdatedAt: *gComment.UpdatedAt,
PullRequest: false,
Repository: strings.ToLower(repository),
}, nil
} | |
c175898 | logrus.Infof("Change %d: Comment %s matches triggering regex, for %s.", change.Number, message.Message, presubmit.Name)
filters = append(filters, pjutil.CommandFilter(message.Message))
}
}
} else {
filters = append(filters, pjutil.TestAllFilter())
}
}
return pjutil.AggregateFilter(filters), nil
} | |
c175899 | nil && *jb.Result == success
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.