8000 fix: cannot find remote branch · githubocto/repo-visualizer@936c35a · GitHub
[go: up one dir, main page]

Skip to content

Commit 936c35a

Browse files
fix: cannot find remote branch
1 parent 2dea7f0 commit 936c35a

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

index.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26275,34 +26275,33 @@ var main = async () => {
2627526275
const maxDepth = core.getInput("max_depth") || 9;
2627626276
const customFileColors = JSON.parse(core.getInput("file_colors") || "{}");
2627726277
const colorEncoding = core.getInput("color_encoding") || "type";
26278-
const commitMessage = core.getInput("commit_message") || "Repo visualizer: updated diagram";
26278+
const commitMessage = core.getInput("commit_message") || "Repo visualizer: update diagram";
2627926279
const excludedPathsString = core.getInput("excluded_paths") || "node_modules,bower_components,dist,out,build,eject,.next,.netlify,.yarn,.git,.vscode,package-lock.json,yarn.lock";
2628026280
const excludedPaths = excludedPathsString.split(",").map((str) => str.trim());
2628126281
const excludedGlobsString = core.getInput("excluded_globs") || "";
2628226282
const excludedGlobs = excludedGlobsString.split(";");
2628326283
const branch = core.getInput("branch");
2628426284
const data = await processDir(rootPath, excludedPaths, excludedGlobs);
26285-
const componentCodeString = import_server.default.renderToStaticMarkup(/* @__PURE__ */ import_react3.default.createElement(Tree, {
26286-
data,
26287-
maxDepth: +maxDepth,
26288-
colorEncoding,
26289-
customFileColors
26290-
}));
26291-
const outputFile = core.getInput("output_file") || "./diagram.svg";
26292-
core.setOutput("svg", componentCodeString);
26293-
await import_fs2.default.writeFileSync(outputFile, componentCodeString);
2629426285
let doesBranchExist = true;
2629526286
if (branch) {
2629626287
await (0, import_exec.exec)("git", ["fetch"]);
2629726288
try {
26298-
await (0, import_exec.exec)("git", ["rev-parse", "--verify", branch]);
26299-
await (0, import_exec.exec)("git", ["checkout", branch]);
26289+
await (0, import_exec.exec)("git", ["switch", "-c", branch, "--track", `origin/${branch}`]);
2630026290
} catch {
2630126291
doesBranchExist = false;
2630226292
core.info(`Branch ${ 8000 branch} does not yet exist, creating ${branch}.`);
2630326293
await (0, import_exec.exec)("git", ["checkout", "-b", branch]);
2630426294
}
2630526295
}
26296+
const componentCodeString = import_server.default.renderToStaticMarkup(/* @__PURE__ */ import_react3.default.createElement(Tree, {
26297+
data,
26298+
maxDepth: +maxDepth,
26299+
colorEncoding,
26300+
customFileColors
26301+
}));
26302+
const outputFile = core.getInput("output_file") || "./diagram.svg";
26303+
core.setOutput("svg", componentCodeString);
26304+
await import_fs2.default.writeFileSync(outputFile, componentCodeString);
2630626305
await (0, import_exec.exec)("git", ["add", outputFile]);
2630726306
const diff = await execWithOutput("git", ["status", "--porcelain", outputFile]);
2630826307
core.info(`diff: ${diff}`);

src/index.jsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,29 @@ const main = async () => {
3838
const branch = core.getInput("branch")
3939
const data = await processDir(rootPath, excludedPaths, excludedGlobs);
4040

41-
const componentCodeString = ReactDOMServer.renderToStaticMarkup(
42-
<Tree data={data} maxDepth={+maxDepth} colorEncoding={colorEncoding} customFileColors={customFileColors}/>
43-
);
44-
45-
const outputFile = core.getInput("output_file") || "./diagram.svg"
46-
47-
core.setOutput('svg', componentCodeString)
48-
49-
await fs.writeFileSync(outputFile, componentCodeString)
50-
5141
let doesBranchExist = true
5242

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

5646
try {
57-
await exec('git', ['rev-parse', '--verify', branch])
58-
await exec('git', ['checkout', branch])
47+
await exec('git', ['switch', '-c' , branch,'--track', `origin/${branch}`])
5948
} catch {
6049
doesBranchExist = false
6150
core.info(`Branch ${branch} does not yet exist, creating ${branch}.`)
6251
await exec('git', ['checkout', '-b', branch])
6352
}
6453
}
54+
const componentCodeString = ReactDOMServer.renderToStaticMarkup(
55+
<Tree data={data} maxDepth={+maxDepth} colorEncoding={colorEncoding} customFileColors={customFileColors}/>
56+
);
57+
58+
const outputFile = core.getInput("output_file") || "./diagram.svg"
59+
60+
core.setOutput('svg', componentCodeString)
61+
62+
await fs.writeFileSync(outputFile, componentCodeString)
63+
6564

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

0 commit comments

Comments
 (0)
0