@hurshb50/setup-ubuntu 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
[user]
|
|
2
|
-
name = Hursh Patel
|
|
3
|
-
email = hurshb50@gmail.com
|
|
4
|
-
|
|
5
1
|
[core]
|
|
6
2
|
editor = zed --wait
|
|
7
3
|
|
|
@@ -29,3 +25,13 @@
|
|
|
29
25
|
[credential "https://github.com"]
|
|
30
26
|
helper =
|
|
31
27
|
helper = !/usr/bin/gh auth git-credential
|
|
28
|
+
|
|
29
|
+
[credential "https://gist.github.com"]
|
|
30
|
+
helper =
|
|
31
|
+
helper = !/usr/bin/gh auth git-credential
|
|
32
|
+
|
|
33
|
+
[includeIf "hasconfig:remote.*.url:https://github.com/rai-inst/**"]
|
|
34
|
+
path = ~/.config/git/work.gitconfig
|
|
35
|
+
|
|
36
|
+
[includeIf "hasconfig:remote.*.url:https://github.com/hurshb50/**"]
|
|
37
|
+
path = ~/.config/git/personal.gitconfig
|
|
@@ -11,7 +11,7 @@ import util from "util";
|
|
|
11
11
|
import childProcess from "child_process";
|
|
12
12
|
//#region package.json
|
|
13
13
|
var name = "@hurshb50/setup-ubuntu";
|
|
14
|
-
var version = "2.0.
|
|
14
|
+
var version = "2.0.4";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region source/modules/logger/logger.ts
|
|
17
17
|
var Logger = class Logger {
|
|
@@ -662,7 +662,28 @@ var VersionControlSystem = class {
|
|
|
662
662
|
const sourceFilePath = path.join(context.directories.assets, ".gitconfig");
|
|
663
663
|
const destinationFilePath = path.join(context.directories.home, ".gitconfig");
|
|
664
664
|
task.continue("Copy configuration");
|
|
665
|
-
await fs.
|
|
665
|
+
const sourceConfiguration = await fs.readFile(sourceFilePath, "utf8");
|
|
666
|
+
let existingConfiguration = "";
|
|
667
|
+
try {
|
|
668
|
+
existingConfiguration = await fs.readFile(destinationFilePath, "utf8");
|
|
669
|
+
} catch (error) {
|
|
670
|
+
if (error.code !== "ENOENT") throw error;
|
|
671
|
+
}
|
|
672
|
+
const userConfigurations = [];
|
|
673
|
+
let currentSection = [];
|
|
674
|
+
let preserveCurrentSection = false;
|
|
675
|
+
for (const line of existingConfiguration.match(/[^\r\n]*(?:\r?\n|$)/g) ?? []) if (/^[ \t]*\[/.test(line)) {
|
|
676
|
+
if (preserveCurrentSection) userConfigurations.push(currentSection.join(""));
|
|
677
|
+
preserveCurrentSection = (line.match(/^[ \t]*\[([^\s\]]+)/)?.[1])?.toLowerCase() === "user";
|
|
678
|
+
currentSection = preserveCurrentSection ? [line] : [];
|
|
679
|
+
} else if (preserveCurrentSection) currentSection.push(line);
|
|
680
|
+
if (preserveCurrentSection) userConfigurations.push(currentSection.join(""));
|
|
681
|
+
const configuration = [...userConfigurations.map((value) => value.trim()), sourceConfiguration.trimEnd()].filter(Boolean).join("\n\n");
|
|
682
|
+
await fs.writeFile(destinationFilePath, `${configuration}\n`);
|
|
683
|
+
task.continue("Copy identity profiles");
|
|
684
|
+
const profilesDirectoryPath = path.join(context.directories.home, ".config", "git");
|
|
685
|
+
await fs.mkdir(profilesDirectoryPath, { recursive: true });
|
|
686
|
+
for (const fileName of ["work.gitconfig", "personal.gitconfig"]) await fs.copyFile(path.join(context.directories.assets, "git", fileName), path.join(profilesDirectoryPath, fileName));
|
|
666
687
|
task.finish();
|
|
667
688
|
}
|
|
668
689
|
};
|