Skip to content

Commit

Permalink
feat(save workflow): rename branch of newly created repo: main to mas…
Browse files Browse the repository at this point in the history
…ter This is a paliative measure

also fix error logic and improve error message
  • Loading branch information
lucaju committed Jul 30, 2021
1 parent cf035f5 commit e9988fd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/GitServerClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ const getMembershipForUser = async ({ owner, username }) => {
return await callCWRCGitWithToken(`${baseUrl}/orgs/${owner}/memberships/${username}`);
};

const createRepo = async ({ repo, description, isPrivate }) => {
const createRepo = async ({ owner, repo, description, isPrivate }) => {
let url = `${baseUrl}/user/repos`;
if (isGitLab) url = `${baseUrl}/projects?name=${repo}`;

return await callCWRCGitWithToken(url, {
method: 'POST',
body: JSON.stringify({ repo, isPrivate, description }),
body: JSON.stringify({ owner, repo, isPrivate, description }),
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/save/CreateRepoModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const CreateRepoModal = ({ cancel, complete, owner, ownerType, repo }) => {

if (ownerType === 'User') {
newRepo = await cwrcGit
.createRepo({ repo, repoDesc, isPrivate })
.createRepo({ owner, repo, repoDesc, isPrivate })
.catch((error) => displayError(error));
} else if (ownerType === 'Organization') {
newRepo = await cwrcGit
Expand Down
9 changes: 4 additions & 5 deletions src/components/save/FileModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,20 @@ const FileModal = ({
// if request from fork action, check file on forked repo
if (fromFork) owner = username;

await cwrcGit
const response = await cwrcGit
.saveDoc({
repo: `${owner}/${repo}`,
path,
content: document,
branch,
message: commitMessage,
})
// eslint-disable-next-line no-unused-vars
.catch((error) => {
if (error.status === 404) {
error.statusText = t('save:error.repoNoPermission');
}
return displayError(error);
displayError(t('save:error.repoNoPermission'));
});

if (!response) return;
complete();
};

Expand Down

0 comments on commit e9988fd

Please sign in to comment.