@@ -50,7 +50,7 @@ async function getOctokit(installationID) {
5050 * // Example usage:
5151 * const myObject = { key: "value" };
5252 * const base64String = jsonToBase64(myObject);
53- * console.log (base64String); // Outputs the Base64 string
53+ * console.debug (base64String); // Outputs the Base64 string
5454 */
5555function jsonToBase64 ( object ) {
5656 const json = JSON . stringify ( object ) ;
@@ -59,7 +59,7 @@ function jsonToBase64(object) {
5959
6060
6161async function getTargetBranch ( octokit , owner , repo , branchName ) {
62- console . log ( 'Fetching details of branch' , branchName ) ;
62+ console . debug ( 'Fetching details of branch' , branchName ) ;
6363 const resp = await octokit . request ( 'GET /repos/{owner}/{repo}/branches/{branch}' , {
6464 owner : owner ,
6565 repo : repo ,
@@ -84,7 +84,7 @@ async function getBranchesNames(octokit, owner, repo) {
8484 const branches = resp . data ;
8585 const allBranchesNames = branches . map ( ( branch ) => branch . name ) ;
8686
87- console . log ( 'All branches names: ' , allBranchesNames )
87+ console . debug ( 'All branches names: ' , allBranchesNames )
8888
8989 return allBranchesNames
9090
@@ -107,7 +107,7 @@ async function getBranchesNames(octokit, owner, repo) {
107107 * @example
108108 * // Example usage:
109109 * const newBranchName = generateBranchName({ allBranchNames: ['master', 'evaluator', 'evaluator-1'] });
110- * console.log (newBranchName); // Outputs: "evaluator-2"
110+ * console.debug (newBranchName); // Outputs: "evaluator-2"
111111 *
112112 * @throws {Error } If the input branches object does not contain a valid array of branch names.
113113 */
@@ -146,12 +146,12 @@ function generateBranchName(branches) {
146146 * @example
147147 * // Example usage:
148148 * const response = await createBranch(octokit, 'exampleUser', 'exampleRepo', 'new-branch', 'abc123def456');
149- * console.log (response.data); // Outputs the details of the created branch
149+ * console.debug (response.data); // Outputs the details of the created branch
150150 *
151151 * @throws {Error } If the GitHub API request fails, an error is thrown with the relevant information.
152152 */
153153async function createBranch ( octokit , owner , repo , branchName , sha ) {
154- console . log ( 'Creating new branch:' , branchName ) ;
154+ console . debug ( 'Creating new branch:' , branchName ) ;
155155
156156 try {
157157 const resp = await octokit . request ( 'POST /repos/{owner}/{repo}/git/refs' , {
@@ -161,7 +161,7 @@ async function createBranch(octokit, owner, repo, branchName, sha) {
161161 sha : sha ,
162162 } ) ;
163163
164- console . log ( 'Branch created successfully:' , branchName ) ;
164+ console . debug ( 'Branch created successfully:' , branchName ) ;
165165 return resp ;
166166 } catch ( error ) {
167167 console . error ( 'Error creating branch:' , error . message ) ;
@@ -190,26 +190,26 @@ async function createBranch(octokit, owner, repo, branchName, sha) {
190190 * @example
191191 * // Example usage:
192192 * const response = await createFile(octokit, 'exampleUser', 'exampleRepo', 'new-branch', 'path/to/file.txt', 'SGVsbG8gd29ybGQ=', 'Add hello world file');
193- * console.log (response.data); // Outputs the details of the created or updated file
193+ * console.debug (response.data); // Outputs the details of the created or updated file
194194 *
195195 * @throws {Error } If an error occurs during the process, an error is thrown with the relevant information.
196196 */
197197async function createFile ( octokit , owner , repo , branchName , path , content , message ) {
198- console . log ( 'Creating or updating file:' , path ) ;
199- console . log ( 'Repository:' , owner , repo ) ;
198+ console . debug ( 'Creating or updating file:' , path ) ;
199+ console . debug ( 'Repository:' , owner , repo ) ;
200200
201201 94727
202202 let contents ;
203203
204204 // Log the content and its type
205- console . log ( 'Content:' , content ) ;
206- console . log ( 'Type of content:' , typeof content ) ;
205+ console . debug ( 'Content:' , content ) ;
206+ console . debug ( 'Type of content:' , typeof content ) ;
207207
208208
209209
210210 // Optionally, you can check if the content is a valid base64 string
211211 const isBase64 = Buffer . from ( content , 'base64' ) . toString ( 'base64' ) === content ;
212- console . log ( 'Is content a valid base64 string?' , isBase64 ) ;
212+ console . debug ( 'Is content a valid base64 string?' , isBase64 ) ;
213213
214214 try {
215215 // Check if the file already exists
@@ -246,14 +246,14 @@ async function createFile(octokit, owner, repo, branchName, path, content, messa
246246 if ( contents && contents . status === 200 ) {
247247 // File already exists, update the file
248248 requestConfig . sha = contents . data . sha ;
249- console . log ( 'File exists, updating:' , path ) ;
249+ console . debug ( 'File exists, updating:' , path ) ;
250250 } else {
251251 // File does not exist, create it
252- console . log ( 'File does not exist, creating:' , path ) ;
252+ console . debug ( 'File does not exist, creating:' , path ) ;
253253 }
254254
255255 const resp = await octokit . request ( 'PUT /repos/{owner}/{repo}/contents/{path}' , requestConfig ) ;
256- console . log ( 'File created/updated successfully:' , path ) ;
256+ console . debug ( 'File created/updated successfully:' , path ) ;
257257 return resp ;
258258 } catch ( error ) {
259259 console . error ( 'Error creating or updating file:' , error . message ) ;
@@ -281,12 +281,12 @@ async function createFile(octokit, owner, repo, branchName, path, content, messa
281281 * @example
282282 * // Example usage:
283283 * const response = await createPullRequest(octokit, 'exampleUser', 'exampleRepo', 'feature-branch', 'main', 'Add new feature', 'This pull request adds a new feature...');
284- * console.log (response.data); // Outputs the details of the created pull request
284+ * console.debug (response.data); // Outputs the details of the created pull request
285285 *
286286 * @throws {Error } If an error occurs during the pull request creation, an error is thrown with the relevant information.
287287 */
288288async function createPullRequest ( octokit , owner , repo , head , base , title , body ) {
289- console . log ( 'Creating pull request from branch:' , head , 'to branch:' , base ) ;
289+ console . debug ( 'Creating pull request from branch:' , head , 'to branch:' , base ) ;
290290
291291 try {
292292 const resp = await octokit . request ( 'POST /repos/{owner}/{repo}/pulls' , {
@@ -299,7 +299,7 @@ async function createPullRequest(octokit, owner, repo, head, base, title, body)
299299 accept : 'application/vnd.github+json'
300300 } ) ;
301301
302- console . log ( 'Pull request created successfully:' , resp . data . html_url ) ;
302+ console . debug ( 'Pull request created successfully:' , resp . data . html_url ) ;
303303 return resp ;
304304 } catch ( error ) {
305305 console . error ( 'Error creating pull request:' , error . message ) ;
0 commit comments