How to use updateReferenceBranch method in argos

Best JavaScript code snippet using argos

Settings.js

Source:Settings.js Github

copy

Full Screen

...27import { useMutation } from "@apollo/client";28import { DocumentationPhrase } from "../../containers/DocumentationPhrase";29import { EnableToggleButton } from "./EnableToggleButton";30const UPDATE_REFERENCE_BRANCH = gql`31 mutation updateReferenceBranch(32 $repositoryId: String!33 $baselineBranch: String34 ) {35 updateReferenceBranch(36 repositoryId: $repositoryId37 baselineBranch: $baselineBranch38 ) {39 id40 baselineBranch41 defaultBranch42 }43 }44`;45function TokenCard({ repository }) {46 return (47 <Card>48 <CardHeader>49 <CardTitle id="argos-token">Argos Token</CardTitle>50 </CardHeader>51 <CardBody>52 <CardText fontSize="md">53 Use this <Tag>ARGOS_TOKEN</Tag> to authenticate your repository when54 you send screenshots to Argos.55 </CardText>56 <Code my={3}>ARGOS_TOKEN={repository.token}</Code>57 <Alert my={3} severity="warning">58 This token should be kept secret.59 </Alert>60 <CardText fontSize="md" mt={4}>61 <DocumentationPhrase />62 </CardText>63 </CardBody>64 </Card>65 );66}67function UpdateBranchForm({ repository }) {68 const successToast = useToast();69 const errorToast = useToast();70 const [baselineBranch, setBaselineBranch] = React.useState(71 repository.baselineBranch || repository.defaultBranch || ""72 );73 const initialUseDefaultBranch = repository.baselineBranch === null;74 const [useDefaultBranch, setUseDefaultBranch] = React.useState(75 initialUseDefaultBranch76 );77 const [updateReferenceBranch, { loading }] = useMutation(78 UPDATE_REFERENCE_BRANCH,79 { onCompleted: () => successToast.show(), onError: () => errorToast.show() }80 );81 const form = useFormState();82 form.useSubmit(async () => {83 await updateReferenceBranch({84 variables: {85 repositoryId: repository.id,86 baselineBranch: useDefaultBranch ? null : baselineBranch,87 },88 });89 });90 return (91 <Form state={form} mt={4}>92 <x.div>93 <FormLabel name="defaultBranch">94 <Checkbox95 name="defaultBranch"96 onChange={(event) => setUseDefaultBranch(event.target.checked)}97 checked={useDefaultBranch}...

Full Screen

Full Screen

Repository.js

Source:Repository.js Github

copy

Full Screen

...36 extend type Mutation {37 "Enable or disable a repository."38 toggleRepository(enabled: Boolean!, repositoryId: String!): Repository!39 "Update repository baseline branch"40 updateReferenceBranch(41 repositoryId: String!42 baselineBranch: String43 ): Repository!44 }45`;46const generateRandomBytes = promisify(crypto.randomBytes);47export async function getRepository({ ownerLogin, name, user }) {48 const owner = await getOwner({ login: ownerLogin });49 if (!owner) return null;50 const repository = await Repository.query().findOne({51 [`${owner.type()}Id`]: owner.id,52 name,53 });54 if (!repository) return null;55 const hasReadPermission = await repository.$checkReadPermission(user);56 if (!hasReadPermission) return null;57 return repository;58}59async function checkUserRepositoryAccess({ user, repositoryId }, { trx }) {60 if (!user) throw new APIError("Invalid user identification");61 const repositoryUser = await Repository.getUsers(repositoryId, {62 trx,63 }).findById(user.id);64 if (!repositoryUser) throw new APIError("Invalid user authorization");65}66export const resolvers = {67 Repository: {68 async token(repository, args, context) {69 const hasWritePermission = await repository.$checkWritePermission(70 context.user71 );72 if (!hasWritePermission) return null;73 return repository.token;74 },75 async owner(repository) {76 return repository.$relatedOwner();77 },78 async permissions(repository, args, context) {79 const hasWritePermission = await repository.$checkWritePermission(80 context.user81 );82 return hasWritePermission ? ["read", "write"] : ["read"];83 },84 async builds(repository, args) {85 const result = await Build.query()86 .where({ repositoryId: repository.id })87 .whereNot({ number: 0 })88 .orderBy("createdAt", "desc")89 .orderBy("number", "desc")90 .range(args.after, args.after + args.first - 1);91 const hasNextPage = args.after + args.first < result.total;92 return {93 pageInfo: {94 totalCount: result.total,95 hasNextPage,96 endCursor: hasNextPage ? args.after + args.first : result.total,97 },98 edges: result.results,99 };100 },101 async build(repository, { number }) {102 return Build.query().findOne({ repositoryId: repository.id, number });103 },104 async sampleBuildId(repository) {105 const build = await Build.query()106 .where({107 repositoryId: repository.id,108 number: 0,109 })110 .limit(1)111 .first();112 return build ? build.id : null;113 },114 },115 Query: {116 async repository(rootObj, args, context) {117 return getRepository({118 ownerLogin: args.ownerLogin,119 name: args.repositoryName,120 user: context.user,121 });122 },123 },124 Mutation: {125 async toggleRepository(source, { repositoryId, enabled }, context) {126 return transaction(async (trx) => {127 await checkUserRepositoryAccess(128 { user: context.user, repositoryId },129 { trx }130 );131 const repository = await Repository.query(trx).patchAndFetchById(132 repositoryId,133 { enabled }134 );135 if (!repository) {136 throw new APIError("Repository not found");137 }138 // We can skip further work when disabling a repository139 if (!enabled) {140 return repository;141 }142 if (!repository.token) {143 const token = await generateRandomBytes(20);144 return Repository.query(trx).patchAndFetchById(repositoryId, {145 token: token.toString("hex"),146 });147 }148 return repository;149 });150 },151 async updateReferenceBranch(152 source,153 { repositoryId, baselineBranch },154 context155 ) {156 return transaction(async (trx) => {157 await checkUserRepositoryAccess(158 { user: context.user, repositoryId },159 { trx }160 );161 return Repository.query(trx).patchAndFetchById(repositoryId, {162 baselineBranch: (baselineBranch ? baselineBranch.trim() : "") || null,163 });164 });165 },...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var _ = require('lodash');2var async = require('async');3var sdk = require('argos-sdk');4var git = require('simple-git')();5var argv = require('yargs').argv;6var config = require('./config');7var updateReferenceBranch = require('./updateReferenceBranch');8var repo = argv.repo;9var branch = argv.branch;10var referenceBranch = argv.referenceBranch;11var options = {12};13updateReferenceBranch(options, function(err, result) {14 console.log('err', err);15 console.log('result', result);16});17var _ = require('lodash');18var async = require('async');19var git = require('simple-git')();20var sdk = require('argos-sdk');21var argv = require('yargs').argv;22var config = require('./config');23module.exports = function(options, callback) {24 var repo = options.repo;25 var branch = options.branch;26 var referenceBranch = options.referenceBranch;27 var repoPath = config.get('reposPath') + '/' + repo;28 async.series([29 function(cb) {30 git.branch({31 }, function(err, result) {32 if (err) {33 cb(err);34 } else {35 if (result.indexOf(branch) === -1) {36 git.checkout(['-b', branch], function(err, result) {37 if (err) {38 cb(err);39 } else {40 cb();41 }42 });43 } else {44 cb();45 }46 }47 });48 },49 function(cb) {50 git.branch({51 }, function(err, result) {52 if (err) {53 cb(err);54 } else {55 if (result.indexOf(referenceBranch) === -1) {56 git.checkout(['-b', referenceBranch], function(err, result) {57 if (err) {58 cb(err);59 } else {60 cb();61 }62 });63 } else {64 cb();65 }66 }67 });68 },69 function(cb) {70 git.checkout(branch, function(err, result) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var updateReferenceBranch = require('argos-sdk').Utility.updateReferenceBranch;2var branch = 'master';3var repo = 'argos-sdk';4var username = 'username';5var password = 'password';6var options = {};7var callback = function(err, response) {8 if (err) {9 return;10 }11};12updateReferenceBranch(branch, repo, username, password, options, callback);

Full Screen

Using AI Code Generation

copy

Full Screen

1require('argos-sdk/src/Models/Offline/Manager').updateReferenceBranch('referenceBranchName');2updateReferenceBranch: function(referenceBranchName) {3 var referenceBranch = this.getReferenceBranch();4 if (referenceBranch) {5 referenceBranch = referenceBranchName;6 }7 }

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