Skip to content

Commit 6c0c904

Browse files
committed
Remove the keeps and shallow options from the repos section.
1 parent ccc23d1 commit 6c0c904

File tree

7 files changed

+21
-65
lines changed

7 files changed

+21
-65
lines changed

DEPS

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
{
2121
"url": "https://${GIT_DOMAIN}/Tencent/tgfx.git",
2222
"commit": "5948d72a0a5320a1ea055f23bc8312b07ab6d72c",
23-
"dir": "third_party/tgfx",
24-
"keeps": [
25-
"third_party"
26-
]
23+
"dir": "third_party/tgfx"
2724
}
2825
]
2926
},

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ Here is an example of DEPS file:
4444
{
4545
"url": "https://${GIT_DOMAIN}/webmproject/libwebp.git",
4646
"commit": "1fe3162541ab2f5ce69aca2e2b593fab60520d34",
47-
"dir": "third_party/libwebp",
48-
"shallow": false
47+
"dir": "third_party/libwebp"
4948
},
5049
{
5150
"url": "https://${GIT_DOMAIN}/libjpeg-turbo/libjpeg-turbo.git",
@@ -55,10 +54,7 @@ Here is an example of DEPS file:
5554
{
5655
"url": "https://${GIT_DOMAIN}/Tencent/tgfx.git",
5756
"commit": "5948d72a0a5320a1ea055f23bc8312b07ab6d72c",
58-
"dir": "third_party/tgfx",
59-
"keeps": [
60-
"third_party"
61-
]
57+
"dir": "third_party/tgfx"
6258
}
6359
]
6460
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "depsync",
3-
"version": "1.3.7",
3+
"version": "1.3.8",
44
"author": "Dom Chen",
55
"homepage": "http://www.idom.me/",
66
"description": "Automatically synchronize the dependencies of a project by the DEPS configuration file.",

src/Config.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,6 @@ function parseRepos(repos, vars, projectPath) {
8484
item.commit = formatString(item.commit, vars);
8585
item.dir = formatString(item.dir, vars);
8686
item.dir = path.resolve(projectPath, item.dir);
87-
let shallow = item.shallow;
88-
if (typeof shallow == "string") {
89-
shallow = formatString(shallow, vars);
90-
item.shallow = (shallow !== "false");
91-
} else if (typeof shallow != "boolean") {
92-
item.shallow = true;
93-
}
94-
let keeps = item.keeps;
95-
item.keeps = [];
96-
if (keeps instanceof Array) {
97-
for (let keep of keeps) {
98-
keep = formatString(keep, vars);
99-
keep = path.resolve(item.dir, keep);
100-
item.keeps.push(keep);
101-
}
102-
}
10387
list.push(item);
10488
}
10589
return list;

src/tasks/DepsTask.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,9 @@ DepsTask.prototype.run = function (callback) {
5151
let tasks = [];
5252
for (let item of config.repos) {
5353
let shallowFile = path.join(item.dir, ".git", "shallow");
54-
let wasShallow = fs.existsSync(shallowFile);
55-
let commit = "";
56-
if (wasShallow) {
57-
let commits = Utils.readFile(shallowFile).split("\n");
58-
if (commits.length > 0) {
59-
commit = commits[commits.length - 1].trim();
60-
}
61-
} else {
62-
let fetchHeadFile = path.join(item.dir, ".git", "FETCH_HEAD");
63-
commit = Utils.readFile(fetchHeadFile).substring(0, 40);
64-
}
65-
let repoDirty = false;
66-
if (commit !== item.commit || wasShallow !== item.shallow) {
67-
repoDirty = true;
54+
let commit = Utils.readFile(shallowFile).substring(0, 40);
55+
let repoDirty = commit !== item.commit;
56+
if (repoDirty) {
6857
tasks.push(new RepoTask(item));
6958
}
7059
if (repoDirty || fs.existsSync(this.unfinishFile)) {

src/tasks/RepoTask.js

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,36 +66,26 @@ RepoTask.prototype.run = function (callback) {
6666
if (this.username && this.password) {
6767
url = AddLoginInfo(url, this.username, this.password);
6868
}
69-
let shallowFile = path.join(item.dir, ".git", "shallow");
70-
let wasShallow = fs.existsSync(shallowFile);
7169
let lfsDir = path.join(item.dir, ".git", "lfs");
7270
let indexFile = path.join(item.dir, ".git", "index");
7371
let tempLFSDir = path.join(item.dir + ".git", "lfs");
7472
let tempIndexFile = path.join(item.dir + ".git", "index");
75-
if (wasShallow !== item.shallow || item.shallow) {
76-
Utils.movePath(lfsDir, tempLFSDir);
77-
Utils.movePath(indexFile, tempIndexFile);
78-
Utils.deletePath(path.join(item.dir + ".git"));
79-
}
80-
let fetchHeadFile = path.join(item.dir, ".git", "FETCH_HEAD");
81-
if (!fs.existsSync(fetchHeadFile)) {
73+
Utils.movePath(lfsDir, tempLFSDir);
74+
Utils.movePath(indexFile, tempIndexFile);
75+
Utils.deletePath(path.join(item.dir, ".git"));
76+
if (!fs.existsSync(item.dir)) {
8277
Utils.createDirectory(item.dir);
83-
Utils.exec("git init -q", item.dir);
84-
Utils.exec("git remote add origin " + url, item.dir);
85-
}
86-
if (item.shallow) {
87-
Utils.exec("git fetch --depth 1 origin " + item.commit, item.dir);
88-
Utils.movePath(tempLFSDir, lfsDir);
89-
Utils.movePath(tempIndexFile, indexFile);
90-
Utils.deleteEmptyDir(path.dirname(tempIndexFile));
91-
} else {
92-
Utils.exec("git fetch origin " + item.commit, item.dir);
9378
}
79+
Utils.exec("git init -q", item.dir);
80+
Utils.exec("git remote add origin " + url, item.dir);
81+
Utils.exec("git fetch --depth 1 origin " + item.commit, item.dir);
82+
Utils.movePath(tempLFSDir, lfsDir);
83+
Utils.movePath(tempIndexFile, indexFile);
84+
Utils.deleteEmptyDir(path.dirname(tempIndexFile));
9485
process.env["GIT_LFS_SKIP_SMUDGE"] = "1";
95-
Utils.exec("git reset --hard FETCH_HEAD && git clean -f", item.dir);
96-
if (item.shallow) {
97-
Utils.writeFile(shallowFile, item.commit);
98-
}
86+
Utils.exec("git reset --hard FETCH_HEAD && git clean -f -q", item.dir);
87+
let shallowFile = path.join(item.dir, ".git", "shallow");
88+
Utils.writeFile(shallowFile, item.commit + "\n");
9989
let lfsConfig = path.join(item.dir, ".gitattributes");
10090
if (fs.existsSync(lfsConfig)) {
10191
Utils.exec("git lfs prune", item.dir);

src/tasks/SubRepoTask.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ SubRepoTask.prototype.run = function (callback) {
5353
}
5454
let result = Utils.execSafe("git lfs fsck", repoPath);
5555
if (result.indexOf("Git LFS fsck OK") === -1) {
56-
Utils.log("【depsync】downloading git lfs objects for: " + repoPath);
56+
Utils.log("【depsync】downloading git lfs objects to: " + repoPath);
5757
Utils.exec("git lfs pull", repoPath, false);
5858
}
5959
}

0 commit comments

Comments
 (0)