Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const mat = await git.statusMatrix({ dir: root })
const modified = Parser.getModifiedFilenames(mat)
const removable = Parser.getRemovableFilenames(mat)
for (const filepath of modified) {
if (removable.includes(filepath)) {
await git.remove({ dir: root, filepath })
} else {
// TODO: Why?????
if (filepath) {
await git.add({ dir: root, filepath })
}
}
}
return git.commit({
dir: root,
message,
author
})
}
// Pass
} else {
await git.init({ dir: projectRoot })
await git.add({
dir: "/playground",
filepath: "README.md"
})
await git.add({
dir: "/playground",
filepath: ".gitignore"
})
await git.add({
dir: "/playground",
filepath: "scratch.md"
})
await git.commit({
author: {
email: "dummy",
name: "system"
},
dir: "/playground",
message: "Init"
})
}
}
});
await migrateSdkIntoLocalRepo(repoDir, remoteSdkUrl, options);
const addedPaths = await getAllStageableFilepathsInRepo(repoDir);
logger.verbose(`Staging ${addedPaths.length} paths`);
for (const addedPath of addedPaths) {
const relativeFilePath = relative(repoDir, addedPath);
// TODO: Got a lot of "oldFs: fs", maybe make some sort of wrapper to avoid this?
await add({
fs: oldFs,
dir: repoDir,
filepath: relativeFilePath,
});
}
logger.verbose(`Committing changes...`);
await commit({
fs: oldFs,
dir: repoDir,
// TODO: This should be configurable
author: {
name: 'Swagger Platform',
email: 'N/A',
},
// TODO: Could have a better message
message: 'Updated SDK',
});
logger.verbose(`Pushing commits...`);
await push({
fs: oldFs,
dir: repoDir,
...gitInfo.auth,
export async function batchUpdateFiles(
projectRoot: string,
files: Array<[string, string]>,
message: string = "Update"
): Promise {
for (const [filename, content] of files) {
await fs.promises.writeFile(path.join(projectRoot, filename), content)
await git.add({ dir: projectRoot, filepath: filename })
}
return git.commit({
dir: projectRoot,
message,
author: { name: "test", email: "test" }
})
}
async commit(message: string): Promise {
console.log(`[GitManager] Committing...`);
const sha = await commit({
dir: this.projectDir,
message: message,
author: {
email: this.email,
name: this.username
}
});
console.log(`[GitManager] Committed ${sha}.`);
}
export async function createProject(newProjectRoot: string): Promise {
await mkdir(newProjectRoot)
await git.init({ dir: newProjectRoot })
const outpath = path.join(newProjectRoot, "README.md")
await writeFile(outpath, "# New Project")
await git.add({ dir: newProjectRoot, filepath: "README.md" })
await git.commit({
dir: newProjectRoot,
author: { name: "system", email: "dummy" },
message: "Init"
})
}
export function commitChanges(
projectRoot: string,
message: string = "Update",
author?: { name: string; email: string }
): Promise {
return git.commit({
author: author || {
email: "dummy",
name: "anonymous"
},
dir: projectRoot,
fs,
message
})
}
const filepath = content.filepath;
const notificationSystem = selectors.notificationSystem(state);
const repo = {
fs,
dir: filepath.substring(0, filepath.lastIndexOf("/"))
};
const response = remote.dialog.showMessageBox({
type: "question",
buttons: ["Yes", "No"],
title: "Confirm",
message: "Commit changes?"
});
if (response == 0) {
return from(
git.commit({ ...repo, message: "chore: updating notebook" })
).pipe(
map(
() =>
actions.gitCommitSuccessful({
contentRef: action.payload.contentRef
}),
notificationSystem.addNotification({
title: "Changes Commited",
message: `Notebook changes have been commited.`,
dismissible: true,
position: "tr",
level: "success"
})
),
catchError(err => actions.gitCommitFailed(err))
);
export function commitChanges(
projectRoot: string,
message: string = "Update",
author: { name: string; email: string }
): Promise {
return git.commit({
author,
dir: projectRoot,
message
})
}
function gitCommit( message ){
git.commit({
dir,
message,
author:{
name:DATA.name,
email:DATA.email
}
}).then(sha=>{
log("Committed: " + sha);
APP.gitRefresh();
}).catch(ex=>{
APP.error("Could not commit: ", ex);
});
}