nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: intuit/auto
Pull request #883 (2020-01-23 17:54:39)

Fix onlyPublishWithReleaseLabel w/o labels
# What Changed

Ensure onlyPublishWithReleaseLabel is checked and respected.

# Why

When you had a PR with no labels at all, `auto` would skip the check for the `release` label. Making it so that there was always a release created.

Todo:

- [x] Add tests

<!-- GITHUB_RELEASE PR BODY: canary-version -->
Published PR with canary version: <details><summary>Published under canary scope @auto-canary</summary>
- `@auto-canary/auto@9.1.1-canary.883.11552.0`
- `@auto-canary/core@9.1.1-canary.883.11552.0`
- `@auto-canary/all-contributors@9.1.1-canary.883.11552.0`
- `@auto-canary/chrome@9.1.1-canary.883.11552.0`
- `@auto-canary/conventional-commits@9.1.1-canary.883.11552.0`
- `@auto-canary/crates@9.1.1-canary.883.11552.0`
- `@auto-canary/first-time-contributor@9.1.1-canary.883.11552.0`
- `@auto-canary/git-tag@9.1.1-canary.883.11552.0`
- `@auto-canary/jira@9.1.1-canary.883.11552.0`
- `@auto-canary/maven@9.1.1-canary.883.11552.0`
- `@auto-canary/npm@9.1.1-canary.883.11552.0`
- `@auto-canary/omit-commits@9.1.1-canary.883.11552.0`
- `@auto-canary/omit-release-notes@9.1.1-canary.883.11552.0`
- `@auto-canary/released@9.1.1-canary.883.11552.0`
- `@auto-canary/s3@9.1.1-canary.883.11552.0`
- `@auto-canary/slack@9.1.1-canary.883.11552.0`
- `@auto-canary/twitter@9.1.1-canary.883.11552.0`
- `@auto-canary/upload-assets@9.1.1-canary.883.11552.0`</details>
<!-- GITHUB_RELEASE PR BODY: canary-version -->



Patch:
diff --git a/packages/core/src/semver.ts b/packages/core/src/semver.ts
index de1762c9..dc8a6618 100644
--- a/packages/core/src/semver.ts
+++ b/packages/core/src/semver.ts
@@ -65,7 +65,7 @@ export function calculateSemVerBump(
 
   let skipRelease = false;
 
-  if (labels.length > 0 && labels[0].length > 0) {
+  if (labels.length > 0) {
     const releaseLabels = labelMap.get('release') || [];
 
     skipRelease = onlyPublishWithReleaseLabel


Test patch:
diff --git a/packages/core/src/__tests__/semver.test.ts b/packages/core/src/__tests__/semver.test.ts
index 8b881124..52fc90bc 100644
--- a/packages/core/src/__tests__/semver.test.ts
+++ b/packages/core/src/__tests__/semver.test.ts
@@ -43,4 +43,12 @@ describe('calculateSemVerBump', () => {
       SEMVER.major
     );
   });
+
+  test('should respect onlyPublishWithReleaseLabel when no labels present', () => {
+    expect(
+      calculateSemVerBump([[]], semverMap, {
+        onlyPublishWithReleaseLabel: true
+      })
+    ).toBe(SEMVER.noVersion);
+  });
 });
Repository: intuit/auto
Pull request #896 (2020-01-25 05:52:47)

add better messaging when pr number cannot be detected
# What Changed

add more informative error message

# Why

there were states where this error would throw and it wasn't immediately obvious why 


<!-- GITHUB_RELEASE PR BODY: canary-version -->
Published PR with canary version: <details><summary>1.2.3-canary.0</summary>
Test out this PR locally via:
```sh
npm install @foobar/app@1.2.3-canary.0
npm install @foobar/lib@1.2.3-canary.0
# or 
yarn add @foobar/app@1.2.3-canary.0
yarn add @foobar/lib@1.2.3-canary.0
```
</details>
<!-- GITHUB_RELEASE PR BODY: canary-version -->



Patch:
diff --git a/packages/core/src/auto.ts b/packages/core/src/auto.ts
index 158e3ee2..d9fc848a 100644
--- a/packages/core/src/auto.ts
+++ b/packages/core/src/auto.ts
@@ -1077,9 +1077,15 @@ export default class Auto {
     const prNumber = getPrNumberFromEnv(pr);
 
     if (!prNumber) {
-      throw new Error(
-        `Could not detect PR number. ${command} must be run from either a PR or have the PR number supplied via the --pr flag.`
+      this.logger.log.error(
+        endent`
+          Could not detect PR number. ${command} must be run from either a PR or have the PR number supplied via the --pr flag.
+          
+          In some CIs your branch might be built before you open a PR and posting the canary version will fail. In this case subsequent builds should succeed. 
+        `
       );
+
+      process.exit(1);
     }
 
     return prNumber;


Test patch:
diff --git a/packages/core/src/__tests__/auto.test.ts b/packages/core/src/__tests__/auto.test.ts
index 1b6a7a45..d2668818 100644
--- a/packages/core/src/__tests__/auto.test.ts
+++ b/packages/core/src/__tests__/auto.test.ts
@@ -355,14 +355,14 @@ describe('Auto', () => {
 
     test('should catch exceptions when status fails to post', async () => {
       const auto = new Auto(defaults);
+
+      process.exit = jest.fn() as any;
       auto.logger = dummyLog();
       await auto.loadConfig();
       auto.git!.createStatus = createStatus;
-      createStatus.mockRejectedValueOnce({ status: 400 });
 
-      await expect(
-        auto.prStatus({ ...required, sha: '1234' })
-      ).rejects.toBeInstanceOf(Error);
+      auto.prStatus({ ...required, sha: '1234' });
+      expect(process.exit).toHaveBeenCalled();
       expect(createStatus).toHaveBeenCalled();
     });
Repository: intuit/auto
Pull request #929 (2020-02-04 19:39:52)

dont run git hooks when commiting the version for a single npm package
# What Changed

See title.

# Why

Git hooks could botch a release.

Todo:

- [x] Add tests



Patch:
diff --git a/plugins/npm/src/index.ts b/plugins/npm/src/index.ts
index 5cfb3ac6..e7bb1169 100644
--- a/plugins/npm/src/index.ts
+++ b/plugins/npm/src/index.ts
@@ -617,6 +617,7 @@ export default class NPMPlugin implements IPlugin {
       await execPromise('npm', [
         'version',
         latestBump || version,
+        '--no-commit-hooks',
         '-m',
         VERSION_COMMIT_MESSAGE,
         ...verboseArgs


Test patch:
diff --git a/plugins/npm/__tests__/npm.test.ts b/plugins/npm/__tests__/npm.test.ts
index ae64b4dc..25f72927 100644
--- a/plugins/npm/__tests__/npm.test.ts
+++ b/plugins/npm/__tests__/npm.test.ts
@@ -391,6 +391,7 @@ describe('publish', () => {
     expect(exec).toHaveBeenCalledWith('npm', [
       'version',
       Auto.SEMVER.patch,
+      '--no-commit-hooks',
       '-m',
       '"Bump version to: %s [skip ci]"',
       '--loglevel',
@@ -419,6 +420,7 @@ describe('publish', () => {
     expect(exec).toHaveBeenCalledWith('npm', [
       'version',
       Auto.SEMVER.patch,
+      '--no-commit-hooks',
       '-m',
       '"Bump version to: %s [skip ci]"'
     ]);
@@ -575,6 +577,7 @@ describe('publish', () => {
     expect(exec).toHaveBeenCalledWith('npm', [
       'version',
       '1.0.1',
+      '--no-commit-hooks',
       '-m',
       '"Bump version to: %s [skip ci]"'
     ]);
Repository: intuit/auto
Pull request #932 (2020-02-06 19:26:24)

create-labels: handle repos with large amounts of labels
# What Changed

correctly handle cases with repo that have more than 20 labels

# Why

`HttpError: Validation Failed: {"resource":"Label","code":"already_exists","field":"name"}`

Todo:

- [x] Add tests
- [x] Add docs



Patch:
diff --git a/packages/core/src/git.ts b/packages/core/src/git.ts
index 33d43906..f4393a72 100644
--- a/packages/core/src/git.ts
+++ b/packages/core/src/git.ts
@@ -290,14 +290,17 @@ export default class Git {
     };
 
     try {
-      const labels = await this.github.issues.listLabelsForRepo(args);
+      const labels: Octokit.IssuesListLabelsForRepoResponse = await this.github.paginate(
+        this.github.issues.listLabelsForRepo.endpoint(args)
+      );
+
       this.logger.veryVerbose.info(
         'Got response for "getProjectLabels":\n',
         labels
       );
-      this.logger.verbose.info('Found labels on project:\n', labels.data);
+      this.logger.verbose.info('Found labels on project:\n', labels);
 
-      return labels.data.map(l => l.name);
+      return labels.map(l => l.name);
     } catch (e) {
       throw new GitAPIError('getProjectLabels', args, e);
     }


Test patch:
diff --git a/packages/core/src/__tests__/git.test.ts b/packages/core/src/__tests__/git.test.ts
index 049898a1..16a5ce2b 100644
--- a/packages/core/src/__tests__/git.test.ts
+++ b/packages/core/src/__tests__/git.test.ts
@@ -46,7 +46,7 @@ jest.mock('@octokit/rest', () => {
       updateComment,
       listComments,
       deleteComment,
-      listLabelsForRepo,
+      listLabelsForRepo: { endpoint: listLabelsForRepo },
       createLabel,
       updateLabel,
       addLabels,
@@ -581,9 +581,9 @@ describe('github', () => {
     test('return labels', async () => {
       const gh = new Git(options);
 
-      listLabelsForRepo.mockReturnValueOnce({
-        data: [{ name: 'first label' }, { name: 'second label' }]
-      });
+      paginate.mockReturnValueOnce(
+        Promise.resolve([{ name: 'first label' }, { name: 'second label' }])
+      );
 
       expect(await gh.getProjectLabels()).toStrictEqual([
         'first label',