diff --git a/src/git/apiHandler.js b/src/git/apiHandler.js index 33367c8..cda6359 100644 --- a/src/git/apiHandler.js +++ b/src/git/apiHandler.js @@ -1310,6 +1310,24 @@ async function updateGiteaRepoTopics({ token, url, owner, repo, topics }) { } } +async function updateGiteaRepoArchived({ token, url, owner, repo, archived }) { + const base = normalizeAndValidateBaseUrl(url); + const endpoint = `${base}/api/v1/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`; + const res = await axiosInstance.patch( + endpoint, + { archived: !!archived }, + { + headers: { + Authorization: `token ${token}`, + 'Content-Type': 'application/json', + 'User-Agent': 'Git-Manager-GUI' + }, + timeout: 15000 + } + ); + return res.data; +} + /* ==================================================== GITHUB API FUNCTIONS ==================================================== */ @@ -1949,6 +1967,30 @@ async function updateGithubRepoTopics({ token, owner, repo, topics }) { return response.data; } +async function updateGithubRepoArchived({ token, owner, repo, archived }) { + const repoPath = `${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`; + const archiveEndpoint = `${GITHUB_API}/repos/${repoPath}/archive`; + + if (archived) { + await axiosInstance.put( + archiveEndpoint, + {}, + { headers: githubHeaders(token), timeout: 15000 } + ); + } else { + await axiosInstance.delete( + archiveEndpoint, + { headers: githubHeaders(token), timeout: 15000 } + ); + } + + const response = await axiosInstance.get( + `${GITHUB_API}/repos/${repoPath}`, + { headers: githubHeaders(token), timeout: 15000 } + ); + return response.data; +} + async function deleteGithubRepo({ token, owner, repo }) { await axiosInstance.delete( `${GITHUB_API}/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`, @@ -1988,6 +2030,7 @@ module.exports = { updateGiteaRepoAvatar, updateGiteaRepoVisibility, updateGiteaRepoTopics, + updateGiteaRepoArchived, migrateRepoToGitea, listGiteaTopicsCatalog, getGiteaCurrentUser, @@ -2032,5 +2075,6 @@ module.exports = { updateGithubRepoVisibility, updateGithubRepoDefaultBranch, updateGithubRepoTopics, + updateGithubRepoArchived, deleteGithubRepo }; \ No newline at end of file diff --git a/src/utils/helpers.js b/src/utils/helpers.js index 06b70d0..8377cc7 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers.js @@ -13,7 +13,7 @@ const ppath = require('path'); const LOG_LEVELS = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 }; let currentLogLevel = process.env.NODE_ENV === 'production' ? LOG_LEVELS.INFO : LOG_LEVELS.DEBUG; let logQueue = []; -const MAX_LOG_BUFFER = 100; +const MAX_LOG_BUFFER = 2000; function formatLog(level, context, message, details = null) { const timestamp = new Date().toISOString();