Skip to content

fix: cannot find remote branch #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26275,34 +26275,33 @@ var main = async () => {
const maxDepth = core.getInput("max_depth") || 9;
const customFileColors = JSON.parse(core.getInput("file_colors") || "{}");
const colorEncoding = core.getInput("color_encoding") || "type";
const commitMessage = core.getInput("commit_message") || "Repo visualizer: updated diagram";
const commitMessage = core.getInput("commit_message") || "Repo visualizer: update diagram";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll want to make this change in src/index.jsx:30

const excludedPathsString = core.getInput("excluded_paths") || "node_modules,bower_components,dist,out,build,eject,.next,.netlify,.yarn,.git,.vscode,package-lock.json,yarn.lock";
const excludedPaths = excludedPathsString.split(",").map((str) => str.trim());
const excludedGlobsString = core.getInput("excluded_globs") || "";
const excludedGlobs = excludedGlobsString.split(";");
const branch = core.getInput("branch");
const data = await processDir(rootPath, excludedPaths, excludedGlobs);
const componentCodeString = import_server.default.renderToStaticMarkup(/* @__PURE__ */ import_react3.default.createElement(Tree, {
data,
maxDepth: +maxDepth,
colorEncoding,
customFileColors
}));
const outputFile = core.getInput("output_file") || "./diagram.svg";
core.setOutput("svg", componentCodeString);
await import_fs2.default.writeFileSync(outputFile, componentCodeString);
let doesBranchExist = true;
if (branch) {
await (0, import_exec.exec)("git", ["fetch"]);
try {
await (0, import_exec.exec)("git", ["rev-parse", "--verify", branch]);
await (0, import_exec.exec)("git", ["checkout", branch]);
await (0, import_exec.exec)("git", ["switch", "-c", branch, "--track", `origin/${branch}`]);
} catch {
doesBranchExist = false;
core.info(`Branch ${branch} does not yet exist, creating ${branch}.`);
await (0, import_exec.exec)("git", ["checkout", "-b", branch]);
}
}
const componentCodeString = import_server.default.renderToStaticMarkup(/* @__PURE__ */ import_react3.default.createElement(Tree, {
data,
maxDepth: +maxDepth,
colorEncoding,
customFileColors
}));
const outputFile = core.getInput("output_file") || "./diagram.svg";
core.setOutput("svg", componentCodeString);
await import_fs2.default.writeFileSync(outputFile, componentCodeString);
await (0, import_exec.exec)("git", ["add", outputFile]);
const diff = await execWithOutput("git", ["status", "--porcelain", outputFile]);
core.info(`diff: ${diff}`);
Expand Down
23 changes: 11 additions & 12 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,29 @@ const main = async () => {
const branch = core.getInput("branch")
const data = await processDir(rootPath, excludedPaths, excludedGlobs);

const componentCodeString = ReactDOMServer.renderToStaticMarkup(
<Tree data={data} maxDepth={+maxDepth} colorEncoding={colorEncoding} customFileColors={customFileColors}/>
);

const outputFile = core.getInput("output_file") || "./diagram.svg"

core.setOutput('svg', componentCodeString)

await fs.writeFileSync(outputFile, componentCodeString)

let doesBranchExist = true

if (branch) {
await exec('git', ['fetch'])

try {
await exec('git', ['rev-parse', '--verify', branch])
await exec('git', ['checkout', branch])
await exec('git', ['switch', '-c' , branch,'--track', `origin/${branch}`])
} catch {
doesBranchExist = false
core.info(`Branch ${branch} does not yet exist, creating ${branch}.`)
await exec('git', ['checkout', '-b', branch])
}
}
const componentCodeString = ReactDOMServer.renderToStaticMarkup(
<Tree data={data} maxDepth={+maxDepth} colorEncoding={colorEncoding} customFileColors={customFileColors}/>
);

const outputFile = core.getInput("output_file") || "./diagram.svg"

core.setOutput('svg', componentCodeString)

await fs.writeFileSync(outputFile, componentCodeString)


await exec('git', ['add', outputFile])
const diff = await execWithOutput('git', ['status', '--porcelain', outputFile])
Expand Down