How to use octokit.git.createCommit method in qawolf

Best JavaScript code snippet using qawolf

github.test.js

Source:github.test.js Github

copy

Full Screen

1const github = require('../src/github')2const helpers = require('./test-helpers')3test('get issue number from branch name', () => {4 expect(github.getIssueNumberFromBranchName('i12')).toBe(12)5 expect(github.getIssueNumberFromBranchName('34-Fix_ugly_bug')).toBe(34)6 expect(github.getIssueNumberFromBranchName('bugfix/34-Fix_ugly_bug')).toBe(34)7 expect(github.getIssueNumberFromBranchName('issue-56')).toBe(56)8 expect(github.getIssueNumberFromBranchName('IsSuE-56')).toBe(56)9 expect(github.getIssueNumberFromBranchName('issue-78-Hello_world_this_is_a_test')).toBe(78)10 expect(github.getIssueNumberFromBranchName('some-prefix-issue-78-Add_more_unit_tests')).toBe(78)11 expect(github.getIssueNumberFromBranchName('feature/some-user/some-prefix-issue-78-Add_more_unit_tests'))12 .toBe(78)13})14test('get branch name from issue', async () => {15 const ctx = { payload: { issue: { number: 12, title: 'Hello world', labels: [{ name: 'bug' }] } } }16 let config = { branchName: 'tiny' }17 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('i12')18 config = { branchName: 'short' }19 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('issue-12')20 config = { branchName: 'full' }21 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('issue-12-Hello_world')22 config = { branches: [{ label: 'bug', prefix: 'bug/' }] }23 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('bug/issue-12-Hello_world')24 config = { branches: [{ label: 'bug', prefix: 'Some bugs here/' }] }25 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('Some_bugs_here/issue-12-Hello_world')26 config = { branches: [{ label: 'bug', prefix: 'feature-2019-12-17T10:16:25Z' }] }27 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('feature-2019-12-17T10_16_25Zissue-12-Hello_world')28 config = { branches: [{ label: 'bug', prefix: 'feature\\' }] }29 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('feature_issue-12-Hello_world')30 // eslint-disable-next-line no-template-curly-in-string31 config = { branchName: '${issue.title}-${issue.number}' }32 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('Hello_world-12')33 // eslint-disable-next-line34 process.env['SOME_VAR'] = 'Hello world'35 // eslint-disable-next-line no-template-curly-in-string36 config = { branchName: '${issue.number}-${%SOME_VAR}' }37 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('12-Hello_world')38})39test('get branch name from issue, reported issues', async () => {40 const ctx = { payload: { issue: { number: 12, title: 'Hello world', labels: [{ name: 'bug' }] } } }41 const config = { branchName: 'full' }42 ctx.payload.issue.title = '"Error: Mysqli statement execute error : Cannot add or update a child row: a ' +43 'foreign key constraint fails (`omeka`.`omeka_super_eight_festivals_filmmaker_films`, CONSTRAINT ' +44 '`omeka_super_eight_festivals_filmmaker_films_ibfk_1` FOREIGN KEY (`filmmaker_id`) REFERENCES ' +45 '`omeka_super_eight_festivals_peop)" when adding filmmaker film #20'46 expect(await github.getBranchNameFromIssue(ctx, config)).toBe(47 'issue-12-_Error_Mysqli_statement_execute_error_Cannot_add_or_update_a_child_row_a_foreign_key_constraint_fails' +48 '_omeka_omeka_super_eight_festivals_filmmaker_films_CONSTRAINT_omeka_super_eight_festivals_filmmaker_films_' +49 'ibfk_1_FOREIGN_KEY_filmmake')50 ctx.payload.issue.title = '全是中文的名字'51 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('issue-12-全是中文的名字')52 ctx.payload.issue.title = '半中文half english'53 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('issue-12-半中文half_english')54})55test('get branch configuration for issue', () => {56 const ctx = { payload: { issue: { labels: [{ name: 'enhancement' }] } } }57 const config = { branches: [{ label: 'enhancement', prefix: 'feature/' }] }58 const branchConfig = github.getIssueBranchConfig(ctx, config)59 expect(branchConfig).toBeDefined()60 expect(branchConfig.prefix).toBe('feature/')61})62test('get branch configuration with multiple labels for issue', () => {63 const ctx = { payload: { issue: { labels: [{ name: 'enhancement' }, { name: 'documentation' }] } } }64 const config = {65 branches: [{ label: ['enhancement', 'documentation'], prefix: 'docs/' },66 { label: 'enhancement', prefix: 'feature/' }]67 }68 const branchConfig = github.getIssueBranchConfig(ctx, config)69 expect(branchConfig).toBeDefined()70 expect(branchConfig.prefix).toBe('docs/')71})72test('get skip is true branch configuration for issue', () => {73 const ctx = { payload: { issue: { labels: [{ name: 'question' }] } } }74 const config = { branches: [{ label: 'question', skip: true }] }75 const branchConfig = github.getIssueBranchConfig(ctx, config)76 expect(branchConfig).toBeDefined()77 expect(branchConfig.skip).toBe(true)78})79test('skip branch creation for issue', () => {80 const questionIssue = { payload: { issue: { labels: [{ name: 'question' }] } } }81 const bugIssue = { payload: { issue: { labels: [{ name: 'bug' }] } } }82 const config = { branches: [{ label: 'question', skip: true }] }83 expect(github.skipBranchCreationForIssue(questionIssue, config)).toBe(true)84 expect(github.skipBranchCreationForIssue(bugIssue, config)).toBe(false)85})86test('get branch configuration for issue with all matching wildcard fallthrough', () => {87 const ctx = { payload: { issue: { labels: [{ name: 'mylabel' }] } } }88 const config = { branches: [{ label: 'enhancement', prefix: 'feature/' }, { label: '*', prefix: 'issues/' }] }89 const branchConfig = github.getIssueBranchConfig(ctx, config)90 expect(branchConfig).toBeDefined()91 expect(branchConfig.prefix).toBe('issues/')92})93test('issue has no branch configuration', () => {94 const ctx = { payload: { issue: { labels: [{ name: 'bug' }] } } }95 const config = { branches: [{ label: 'enhancement', prefix: 'feature/' }] }96 const branchConfig = github.getIssueBranchConfig(ctx, config)97 expect(branchConfig).toBeUndefined()98})99test('get issue branch prefix', () => {100 const ctx = { payload: { issue: { labels: [{ name: 'enhancement' }] } } }101 const config = { branches: [{ label: 'enhancement', prefix: 'feature/' }] }102 const prefix = github.getIssueBranchPrefix(ctx, config)103 expect(prefix).toBe('feature/')104})105test('get issue branch prefix for issue that has no branch configuration', () => {106 const ctx = { payload: { issue: { labels: [{ name: 'bug' }] } } }107 const config = { branches: [{ label: 'enhancement', prefix: 'feature/' }] }108 const prefix = github.getIssueBranchPrefix(ctx, config)109 expect(prefix).toBe('')110})111test('get issue branch prefix with context expression interpolation', () => {112 const ctx = { payload: { issue: { labels: [{ name: 'enhancement' }], user: { login: 'robvanderleek' } } } }113 // eslint-disable-next-line no-template-curly-in-string114 const config = { branches: [{ label: 'enhancement', prefix: 'feature/${issue.user.login}/' }] }115 const prefix = github.getIssueBranchPrefix(ctx, config)116 expect(prefix).toBe('feature/robvanderleek/')117})118test('get branch name from issue with only branch prefix configured', async () => {119 const ctx = { payload: { issue: { number: 12, title: 'Hello world', labels: [{ name: 'enhancement' }] } } }120 const config = { branchName: 'short', branches: [{ label: 'enhancement', prefix: 'feature/' }] }121 expect(await github.getBranchNameFromIssue(ctx, config)).toBe('feature/issue-12')122})123test('handle branch already exist, log message to info level', async () => {124 const createRef = () => {125 // eslint-disable-next-line no-throw-literal126 throw { message: 'Reference already exists' }127 }128 const ctx = helpers.getDefaultContext()129 ctx.octokit.git.createRef = createRef130 const log = { info: jest.fn() }131 await github.createBranch(ctx, {}, 'issue-1', '1234abcd', log)132 expect(log.info).toBeCalled()133})134test('log branch create errors with error level', async () => {135 const createComment = jest.fn()136 const createRef = () => {137 // eslint-disable-next-line no-throw-literal138 throw { message: 'Oops, something is wrong' }139 }140 const ctx = helpers.getDefaultContext()141 ctx.octokit.issues.createComment = createComment142 ctx.octokit.git.createRef = createRef143 await github.createBranch(ctx, { silent: false }, 'robvanderleek', 'create-issue-branch', 'issue-1', '1234abcd',144 () => {})145 expect(createComment).toBeCalled()146})147test('create (draft) PR', async () => {148 const createPR = jest.fn()149 let capturedCommitMessage = ''150 const createCommit = ({ message }) => {151 capturedCommitMessage = message152 return ({ data: { sha: 'abcd1234' } })153 }154 const ctx = helpers.getDefaultContext()155 ctx.octokit.pulls.create = createPR156 ctx.octokit.git.createCommit = createCommit157 await github.createPR({ log: () => { } }, ctx, { silent: false }, 'robvanderleek', 'issue-1')158 expect(createPR).toHaveBeenCalledWith({159 owner: 'robvanderleek',160 repo: 'create-issue-branch',161 draft: false,162 base: 'master',163 head: 'issue-1',164 body: 'closes #1',165 title: 'Hello world'166 })167 expect(capturedCommitMessage).toBe('Create PR for #1')168 await github.createPR({ log: () => { } }, ctx, { silent: false, openDraftPR: true }, 'robvanderleek', 'issue-1')169 expect(createPR).toHaveBeenCalledWith({170 owner: 'robvanderleek',171 repo: 'create-issue-branch',172 draft: true,173 base: 'master',174 head: 'issue-1',175 body: 'closes #1',176 title: 'Hello world'177 })178 expect(capturedCommitMessage).toBe('Create draft PR for #1')179})180test('copy Issue description into PR', async () => {181 const createPR = jest.fn()182 const createCommit = () => ({ data: { sha: 'abcd1234' } })183 const ctx = helpers.getDefaultContext()184 ctx.octokit.pulls.create = createPR185 ctx.octokit.git.createCommit = createCommit186 ctx.payload.issue.body = 'This is the description'187 await github.createPR({ log: () => { } }, ctx, { copyIssueDescriptionToPR: true, silent: false }, 'robvanderleek',188 'issue-1')189 expect(createPR).toHaveBeenCalledWith({190 owner: 'robvanderleek',191 repo: 'create-issue-branch',192 draft: false,193 base: 'master',194 head: 'issue-1',195 body: 'This is the description\ncloses #1',196 title: 'Hello world'197 })198})199test('Do not copy undefined Issue description into PR', async () => {200 const createPR = jest.fn()201 const createCommit = () => ({ data: { sha: 'abcd1234' } })202 const ctx = helpers.getDefaultContext()203 ctx.octokit.pulls.create = createPR204 ctx.octokit.git.createCommit = createCommit205 ctx.payload.issue.body = null206 await github.createPR({ log: () => { } }, ctx, { copyIssueDescriptionToPR: true, silent: false }, 'robvanderleek',207 'issue-1')208 expect(createPR).toHaveBeenCalledWith({209 owner: 'robvanderleek',210 repo: 'create-issue-branch',211 draft: false,212 base: 'master',213 head: 'issue-1',214 body: 'closes #1',215 title: 'Hello world'216 })217})218test('use correct source branch', async () => {219 const createPR = jest.fn()220 const ctx = helpers.getDefaultContext()221 ctx.octokit.pulls.create = createPR222 ctx.payload.issue.labels = [{ name: 'enhancement' }]223 const config = { branches: [{ label: 'enhancement', name: 'develop' }] }224 await github.createPR({ log: () => { } }, ctx, config, 'robvanderleek', 'issue-1')225 expect(createPR).toHaveBeenCalledWith({226 owner: 'robvanderleek',227 repo: 'create-issue-branch',228 draft: false,229 base: 'develop',230 head: 'issue-1',231 body: 'closes #1',232 title: 'Hello world'233 })234})235test('use configured target branch', async () => {236 const createPR = jest.fn()237 const ctx = helpers.getDefaultContext()238 ctx.octokit.pulls.create = createPR239 ctx.payload.issue.labels = [{ name: 'enhancement' }]240 const config = { branches: [{ label: 'enhancement', prTarget: 'develop' }] }241 await github.createPR({ log: () => { } }, ctx, config, 'robvanderleek', 'issue-1')242 expect(createPR).toHaveBeenCalledWith({243 owner: 'robvanderleek',244 repo: 'create-issue-branch',245 draft: false,246 base: 'develop',247 head: 'issue-1',248 body: 'closes #1',249 title: 'Hello world'250 })251})252test('configured source and target branch', async () => {253 const createPR = jest.fn()254 const ctx = helpers.getDefaultContext()255 ctx.octokit.pulls.create = createPR256 ctx.payload.issue.labels = [{ name: 'hotfix' }]257 const config = { branches: [{ label: 'hotfix', name: 'develop', prTarget: 'hotfix' }] }258 await github.createPR({ log: () => { } }, ctx, config, 'robvanderleek', 'issue-1')259 expect(createPR).toHaveBeenCalledWith({260 owner: 'robvanderleek',261 repo: 'create-issue-branch',262 draft: false,263 base: 'hotfix',264 head: 'issue-1',265 body: 'closes #1',266 title: 'Hello world'267 })268})269test('copy Issue milestone into PR', async () => {270 const updateIssue = jest.fn()271 const createCommit = () => ({ data: { sha: 'abcd1234' } })272 const ctx = helpers.getDefaultContext()273 ctx.octokit.pulls.create = () => ({ data: { number: 123 } })274 ctx.octokit.issues.update = updateIssue275 ctx.octokit.git.createCommit = createCommit276 ctx.payload.issue.body = 'This is the description'277 ctx.payload.issue.milestone = { number: 456 }278 await github.createPR({ log: () => { } }, ctx, { copyIssueMilestoneToPR: true, silent: false }, 'robvanderleek',279 'issue-1')280 expect(updateIssue).toHaveBeenCalledWith({281 owner: 'robvanderleek', repo: 'create-issue-branch', issue_number: 123, milestone: 456282 })...

Full Screen

Full Screen

commit-and-push.ts

Source:commit-and-push.ts Github

copy

Full Screen

1// Copyright 2020 Google LLC2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14/* eslint-disable node/no-unsupported-features/node-builtins */15import * as assert from 'assert';16import {describe, it, before, afterEach} from 'mocha';17import {octokit, setup} from './util';18import * as sinon from 'sinon';19import {GetResponseTypeFromEndpointMethod} from '@octokit/types';20import * as handler from '../src/github/commit-and-push';21import {Changes, FileData, TreeObject, RepoDomain} from '../src/types';22type GetCommitResponse = GetResponseTypeFromEndpointMethod<23 typeof octokit.git.getCommit24>;25type CreateTreeResponse = GetResponseTypeFromEndpointMethod<26 typeof octokit.git.createTree27>;28type CreateCommitResponse = GetResponseTypeFromEndpointMethod<29 typeof octokit.git.createCommit30>;31before(() => {32 setup();33});34describe('Push', () => {35 const sandbox = sinon.createSandbox();36 const origin: RepoDomain = {37 owner: 'Foo',38 repo: 'Bar',39 };40 const sha = 'asdf1234';41 afterEach(() => {42 sandbox.restore();43 });44 it('GitHub tree objects that are generated correctly for text files in a sub-directory', () => {45 const changes: Changes = new Map();46 changes.set('a/foo.txt', new FileData('Foo content'));47 assert.deepStrictEqual(handler.generateTreeObjects(changes), [48 {49 path: 'a/foo.txt',50 mode: '100644',51 type: 'blob',52 content: 'Foo content',53 },54 ]);55 });56 it('has objects that are generated correctly for text files that are deleted', () => {57 const changes: Changes = new Map();58 changes.set('b/bar.txt', new FileData(null));59 assert.deepStrictEqual(handler.generateTreeObjects(changes), [60 {61 path: 'b/bar.txt',62 mode: '100644',63 type: 'blob',64 sha: null,65 },66 ]);67 });68 it('has objects that are generated correctly for deleted exe files', () => {69 const changes: Changes = new Map();70 changes.set('baz.exe', new FileData(null, '100755'));71 assert.deepStrictEqual(handler.generateTreeObjects(changes), [72 {73 path: 'baz.exe',74 mode: '100755',75 type: 'blob',76 sha: null,77 },78 ]);79 });80 it('has objects that are generated correctly for empty text files', () => {81 const changes: Changes = new Map();82 changes.set('empty.txt', new FileData(''));83 assert.deepStrictEqual(handler.generateTreeObjects(changes), [84 {85 path: 'empty.txt',86 mode: '100644',87 type: 'blob',88 content: '',89 },90 ]);91 });92 it('Calls octokit functions with correct params', async () => {93 const tree: TreeObject[] = [94 {95 path: 'a/foo.txt',96 mode: '100644',97 type: 'blob',98 content: 'Foo content',99 },100 {101 path: 'b/bar.txt',102 mode: '100644',103 type: 'blob',104 sha: null,105 },106 {107 path: 'baz.exe',108 mode: '100755',109 type: 'blob',110 sha: null,111 },112 {113 path: 'empty.txt',114 mode: '100644',115 type: 'blob',116 content: '',117 },118 ];119 const commitResponseData = await import(120 './fixtures/get-commit-response.json'121 );122 const createTreeResponseData = await import(123 './fixtures/create-tree-response.json'124 );125 const getCommitResponse = {126 headers: {},127 status: 200,128 url: 'http://fake-url.com',129 data: commitResponseData,130 } as unknown as GetCommitResponse;131 const createTreeResponse = {132 headers: {},133 status: 201,134 url: 'http://fake-url.com',135 data: createTreeResponseData,136 } as unknown as CreateTreeResponse;137 // setup138 const stubGetCommit = sandbox139 .stub(octokit.git, 'getCommit')140 .resolves(getCommitResponse);141 const stubCreateTree = sandbox142 .stub(octokit.git, 'createTree')143 .resolves(createTreeResponse);144 // tests145 const treeSha = await handler.createTree(octokit, origin, sha, tree);146 sandbox.assert.calledOnceWithExactly(stubGetCommit, {147 owner: origin.owner,148 repo: origin.repo,149 commit_sha: sha,150 });151 sandbox.assert.calledWithExactly(stubCreateTree, {152 owner: origin.owner,153 repo: origin.repo,154 tree,155 base_tree: getCommitResponse.data.tree.sha,156 });157 assert.strictEqual(treeSha, createTreeResponse.data.sha);158 });159});160describe('Commit', () => {161 const sandbox = sinon.createSandbox();162 afterEach(() => {163 sandbox.restore();164 });165 const origin: RepoDomain = {166 owner: 'Foo',167 repo: 'Bar',168 };169 const treeSha = 'TREE-asfd1234';170 const head = 'head-asdf1234';171 const message = 'Hello world';172 it('Invokes octokit function called with correct values', async () => {173 // setup174 const createCommitResponseData = await import(175 './fixtures/create-commit-response.json'176 );177 const createCommitResponse = {178 headers: {},179 status: 201,180 url: 'http://fake-url.com',181 data: createCommitResponseData,182 } as unknown as CreateCommitResponse;183 const stubCreateCommit = sandbox184 .stub(octokit.git, 'createCommit')185 .resolves(createCommitResponse);186 // tests187 const sha = await handler.createCommit(188 octokit,189 origin,190 head,191 treeSha,192 message193 );194 assert.strictEqual(sha, createCommitResponse.data.sha);195 sandbox.assert.calledOnceWithExactly(stubCreateCommit, {196 owner: origin.owner,197 repo: origin.repo,198 message,199 tree: treeSha,200 parents: [head],201 });202 });203});204describe('Update branch reference', () => {205 const sandbox = sinon.createSandbox();206 afterEach(() => {207 sandbox.restore();208 });209 const origin: RepoDomain = {210 owner: 'Foo',211 repo: 'Bar',212 };213 const sha = 'asdf1234';214 it('Invokes octokit function called with correct values', async () => {215 // setup216 const stubUpdateRef = sandbox.stub(octokit.git, 'updateRef');217 // tests218 await handler.updateRef(219 octokit,220 {branch: 'test-branch-name', ...origin},221 sha,222 false223 );224 sandbox.assert.calledOnceWithExactly(stubUpdateRef, {225 owner: origin.owner,226 repo: origin.repo,227 sha,228 ref: 'heads/test-branch-name',229 force: false,230 });231 });232});233describe('Commit and push function', async () => {234 const sandbox = sinon.createSandbox();235 const oldHeadSha = 'OLD-head-Sha-asdf1234';236 const changes: Changes = new Map();237 const origin: RepoDomain = {238 owner: 'Foo',239 repo: 'Bar',240 };241 const branchName = 'test-branch-name';242 const message = 'Hello world';243 const commitResponseData = await import(244 './fixtures/get-commit-response.json'245 );246 const createTreeResponseData = await import(247 './fixtures/create-tree-response.json'248 );249 const getCommitResponse = {250 headers: {},251 status: 200,252 url: 'http://fake-url.com',253 data: commitResponseData,254 } as unknown as GetCommitResponse;255 const createTreeResponse = {256 headers: {},257 status: 201,258 url: 'http://fake-url.com',259 data: createTreeResponseData,260 } as unknown as CreateTreeResponse;261 const createCommitResponseData = await import(262 './fixtures/create-commit-response.json'263 );264 const createCommitResponse = {265 headers: {},266 status: 201,267 url: 'http://fake-url.com',268 data: createCommitResponseData,269 } as unknown as CreateCommitResponse;270 afterEach(() => {271 sandbox.restore();272 });273 it('When everything works it calls functions with correct parameter values', async () => {274 // setup275 const stubGetCommit = sandbox276 .stub(octokit.git, 'getCommit')277 .resolves(getCommitResponse);278 const stubCreateTree = sandbox279 .stub(octokit.git, 'createTree')280 .resolves(createTreeResponse);281 const stubCreateCommit = sandbox282 .stub(octokit.git, 'createCommit')283 .resolves(createCommitResponse);284 const stubUpdateRef = sandbox.stub(octokit.git, 'updateRef');285 // tests286 await handler.commitAndPush(287 octokit,288 oldHeadSha,289 changes,290 {branch: branchName, ...origin},291 message,292 true293 );294 sandbox.assert.calledOnceWithExactly(stubGetCommit, {295 owner: origin.owner,296 repo: origin.repo,297 commit_sha: oldHeadSha,298 });299 sandbox.assert.calledWithExactly(stubCreateTree, {300 owner: origin.owner,301 repo: origin.repo,302 tree: [],303 base_tree: getCommitResponse.data.tree.sha,304 });305 sandbox.assert.calledOnceWithExactly(stubCreateCommit, {306 owner: origin.owner,307 repo: origin.repo,308 message,309 tree: createTreeResponse.data.sha,310 parents: [oldHeadSha],311 });312 sandbox.assert.calledOnceWithExactly(stubUpdateRef, {313 owner: origin.owner,314 repo: origin.repo,315 sha: createCommitResponse.data.sha,316 ref: 'heads/test-branch-name',317 force: true,318 });319 });320 it('Forwards GitHub error if getCommit fails', async () => {321 const error = new Error('Error committing');322 sandbox.stub(octokit.git, 'getCommit').rejects(error);323 await assert.rejects(handler.createTree(octokit, origin, '', []), error);324 });325 it('Forwards GitHub error if createTree fails', async () => {326 // setup327 const error = new Error('Error committing');328 sandbox.stub(octokit.git, 'getCommit').resolves(getCommitResponse);329 sandbox.stub(octokit.git, 'createTree').rejects(error);330 // tests331 await assert.rejects(handler.createTree(octokit, origin, '', []), error);332 });...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...27 type: 'blob',28 sha: (await octokit.git.createBlob({ owner, repo, content })).data.sha29 })))30 })).data.sha;31 const sha = (await octokit.git.createCommit({32 owner, repo, message, tree, parents: [commit_sha]33 })).data.sha;34 console.log(await octokit.git.updateRef({ owner, repo, ref, sha }));...

Full Screen

Full Screen

createPullRequest.js

Source:createPullRequest.js Github

copy

Full Screen

...28 }29 })30 })31 const newTreeSha = response.data.sha32 response = await octokit.git.createCommit({33 owner,34 repo,35 message: changes.commit,36 tree: newTreeSha,37 parents: [latestCommitSha]38 })39 latestCommitSha = response.data.sha40 await octokit.git.createRef({41 owner,42 repo,43 sha: latestCommitSha,44 ref: `refs/heads/${head}`45 })46 response = await octokit.pulls.create({...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const core = require('@actions/core');2const github = require('@actions/github');3const fs = require('fs');4const path = require('path');5const { Octokit } = require("@octokit/rest");6async function run() {7 try {8 const token = core.getInput('github-token', { required: true });9 const octokit = new Octokit({10 auth: `token ${token}`,11 });12 const repo = github.context.repo;13 const branch = 'main';14 const base = await octokit.git.getRef({15 ref: `heads/${branch}`,16 });17 const baseSha = base.data.object.sha;18 .readFileSync(path.join(__dirname, 'test.json'))19 .toString();20 const fileSha = await octokit.git.createBlob({21 });22 const tree = await octokit.git.createTree({23 {24 },25 });26 const commit = await octokit.git.createCommit({27 });28 await octokit.git.updateRef({29 ref: `heads/${branch}`,30 });31 } catch (error) {32 core.setFailed(error.message);33 }34}35run();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful