async function pushToRepo(remoteUrl, options, filePath, message) {
try {
// Reading file content from file path and encoding to base64 format
const fileContent = fs.readFileSync(filePath);
const base64Content = fileContent.toString('base64');
const formData = new FormData();
formData.append('message', message);
formData.append('content', base64Content);
formData.append('branch', options.branchName);
const config = {
headers: {
...formData.getHeaders(),
'User-Agent': 'MyApp/1.0.0', // Optional, but recommended
},
auth: {
username: options.username,
password: options.password,
},
jar: true, // enabling cookie jar support
};
const resp = await axios.post(remoteUrl, formData, config);
// Logging success message with response body
console.log('Push to repo successful!', resp.body);
} catch (err) {
// Logging error message
console.error('Error pushing to repo:', err);
}
}
but it is showing
code: 'ERR_FR_TOO_MANY_REDIRECTS'
i got the remote url using
git remote get-url origin
and the url is
https://user_name@bitbucket.org/my-demo/helpcoin.git
password I am using generated from app password from bitbucket
and push is working in that but problem with commit as mentioned in question.
So using the code, in which I don't need to clone the whole repo
what is the issue in this? Am I missing something?