How to use octokit.git.updateRef method in qawolf

Best JavaScript code snippet using qawolf

utils.ts

Source:utils.ts Github

copy

Full Screen

...87 parents: [lastCommit],88 tree: newTree.data.sha,89 }),90 )91 await context.octokit.git.updateRef(92 context.repo({93 ref: editingBranch.ref.replace(/^refs\//, ''),94 sha: commit.data.sha,95 }),96 )97}98export function createComment(context: Context<any>, message: string) {99 return context.octokit.issues.createComment(context.issue({ body: message }))100}101export function createLiveComment(context: Context<any>, initMessage: string) {102 const { issues } = context.octokit103 return async (message: string) => {104 const { data } = await createComment(context, initMessage)105 return issues.updateComment(context.issue({ body: message, comment_id: data.id }))106 }107}108export function forcePush(context: Context<any>, pushingCommit: string, pushedBranch: string) {109 return context.octokit.git.updateRef(110 context.repo({111 ref: `heads/${pushedBranch}`,112 sha: pushingCommit,113 force: true,114 }),115 )116}117export async function merge(118 context: Context<Webhooks.EventPayloads.WebhookPayloadPullRequest>,119 pr: { mergeable: null | boolean; number: number },120 message: string,121 sha: string,122) {123 if (pr.mergeable !== true) return false...

Full Screen

Full Screen

main.test.ts

Source:main.test.ts Github

copy

Full Screen

1import { updateBranch } from '../src/update-branch';2const defaultOptions = {3 octokit: null,4 branch: '',5 ref: '',6 repo: '',7 sha: '',8 force: false,9};10it('should skip if same branch', async () => {11 const res = await updateBranch({12 ...defaultOptions,13 branch: 'prod',14 ref: 'refs/heads/prod',15 });16 expect(res).toMatchObject({17 type: 'warning',18 msg: 'Commit is already on the destination branch, ignoring',19 });20});21describe('tag handling', () => {22 it('should load head commits', async () => {23 const listBranchesForHeadCommit = jest.fn(() => ({ data: [] }));24 const res = await updateBranch({25 ...defaultOptions,26 branch: 'prod',27 ref: 'refs/tags/v1.0.0',28 sha: '0a8e3efc3b91cc0f006aadaced32a8d6f7d9261f',29 octokit: {30 repos: { listBranchesForHeadCommit },31 git: { updateRef: jest.fn() },32 },33 });34 expect(listBranchesForHeadCommit).toHaveBeenCalledWith(expect.objectContaining({35 commit_sha: '0a8e3efc3b91cc0f006aadaced32a8d6f7d9261f',36 }));37 });38 it('should skip if commit not head of any branch', async () => {39 const res = await updateBranch({40 ...defaultOptions,41 branch: 'prod',42 ref: 'refs/tags/v1.0.0',43 sha: '0a8e3efc3b91cc0f006aadaced32a8d6f7d9261f',44 octokit: {45 repos: { listBranchesForHeadCommit: jest.fn(() => ({ data: [] })) },46 git: { updateRef: jest.fn() },47 },48 });49 expect(res).toMatchObject({50 type: 'warning',51 msg: 'Tag isn\'t head of any branches',52 });53 });54 it('should skip if commit is not on protected branch', async () => {55 const res = await updateBranch({56 ...defaultOptions,57 branch: 'prod',58 ref: 'refs/tags/v1.0.0',59 sha: '0a8e3efc3b91cc0f006aadaced32a8d6f7d9261f',60 octokit: {61 repos: { listBranchesForHeadCommit: jest.fn(() => ({ data: [{ protected: false }] })) },62 git: { updateRef: jest.fn() },63 },64 });65 expect(res).toMatchObject({66 type: 'warning',67 msg: 'A tag was pushed but isn\'t head of a protected branch, skipping',68 });69 });70 it('should work if tag is head on protected branch', async () => {71 const res = await updateBranch({72 ...defaultOptions,73 branch: 'prod',74 ref: 'refs/tags/v1.0.0',75 sha: '0a8e3efc3b91cc0f006aadaced32a8d6f7d9261f',76 octokit: {77 repos: { listBranchesForHeadCommit: jest.fn(() => ({ data: [{ protected: true }] })) },78 git: { updateRef: jest.fn() },79 },80 });81 expect(res).toBeNull();82 });83});84it('should work if commit is head on protected branch', async () => {85 const updateRef = jest.fn();86 const res = await updateBranch({87 ...defaultOptions,88 branch: 'prod',89 ref: 'refs/heads/master',90 sha: '0a8e3efc3b91cc0f006aadaced32a8d6f7d9261f',91 octokit: { git: { updateRef } },92 });93 expect(res).toBeNull();94 expect(updateRef).toHaveBeenCalledWith(expect.objectContaining({95 sha: '0a8e3efc3b91cc0f006aadaced32a8d6f7d9261f',96 ref: 'heads/prod',97 }));98});99it('should pass the force option', async () => {100 const updateRef = jest.fn();101 const res = await updateBranch({102 ...defaultOptions,103 octokit: { git: { updateRef } },104 force: true,105 });106 expect(res).toBeNull();107 expect(updateRef).toHaveBeenCalledWith(expect.objectContaining({108 force: true,109 }));...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...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

index.js

Source:index.js Github

copy

Full Screen

...6const { owner, repo } = context.repo;7const sha = context.sha;8const branch = core.getInput('target-branch', {required: true});9const force = (core.getInput('force') || 'false').toUpperCase() === 'TRUE'10octokit.git.updateRef({owner, repo, ref: `heads/${branch}`, sha, force}).11 catch(error => {12 core.setFailed(`Failed to update ref: ${error}`);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Octokit } = require("@octokit/rest");2const octokit = new Octokit({3});4async function updateRef() {5 const params = {6 };7 const response = await octokit.git.updateRef(params);8 console.log(response.data);9}10updateRef();11const { Octokit } = require("@octokit/rest");12const octokit = new Octokit({13});14async function getRef() {15 const params = {16 };17 const response = await octokit.git.getRef(params);18 console.log(response.data);19}20getRef();

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