Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: third_party/WebKit/Source/devtools/scripts/hosted_mode/server.js

Issue 2489033003: DevTools: hosted mode fallback if generated files aren't uploaded yet (Closed)
Patch Set: fix the git grep so it works on full & front-end checkout Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/scripts/utils.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 var fs = require("fs"); 4 var fs = require("fs");
5 var http = require("http"); 5 var http = require("http");
6 var path = require("path"); 6 var path = require("path");
7 var parseURL = require("url").parse; 7 var parseURL = require("url").parse;
8 8
9 var utils = require("../utils"); 9 var utils = require("../utils");
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 var commitHash = match[1]; 109 var commitHash = match[1];
110 var proxyFileURL = proxyFilePathToURL[filePath](commitHash); 110 var proxyFileURL = proxyFilePathToURL[filePath](commitHash);
111 return proxyFileURL; 111 return proxyFileURL;
112 } 112 }
113 113
114 function onProxyFileURL(proxyFileURL) 114 function onProxyFileURL(proxyFileURL)
115 { 115 {
116 if (proxyFileCache.has(proxyFileURL)) 116 if (proxyFileCache.has(proxyFileURL))
117 return Promise.resolve(proxyFileCache.get(proxyFileURL)); 117 return Promise.resolve(proxyFileCache.get(proxyFileURL));
118 return utils.fetch(proxyFileURL) 118 return utils.fetch(proxyFileURL)
119 .then(cacheProxyFile.bind(null, proxyFileURL)); 119 .then(cacheProxyFile.bind(null, proxyFileURL))
120 .catch(onMissingFile);
121 }
122
123 function onMissingFile() {
124 var isFullCheckout = utils.shellOutput("git config --get remote.origin.u rl") === "https://chromium.googlesource.com/chromium/src.git";
125 var earlierCommitHash;
126 var gitLogCommand = `git log --max-count=1 --grep="Commit-Position" --be fore="12 hours ago"`;
chenwilliam 2016/11/14 23:47:30 fixed the git grep so it works on full & front-end
127 if (isFullCheckout) {
128 earlierCommitHash = utils.shellOutput(`${gitLogCommand} --pretty=for mat:"%H"`);
129 } else {
130 var commitMessage = utils.shellOutput(`${gitLogCommand}`);
131 earlierCommitHash = commitMessage.match(/Cr-Mirrored-Commit: (.*)/)[ 1];
132 }
133 var fallbackURL = proxyFilePathToURL[filePath](earlierCommitHash);
134 console.log("WARNING: Unable to fetch generated file based on browser's revision");
135 console.log("Fetching earlier revision of same file as fallback");
136 console.log("There may be a mismatch between the front-end and back-end" );
137 console.log(fallbackURL, "\n");
138 return utils.fetch(fallbackURL)
139 .then(cacheProxyFile.bind(null, fallbackURL));
120 } 140 }
121 141
122 function cacheProxyFile(proxyFileURL, data) 142 function cacheProxyFile(proxyFileURL, data)
123 { 143 {
124 proxyFileCache.set(proxyFileURL, data); 144 proxyFileCache.set(proxyFileURL, data);
125 return data; 145 return data;
126 } 146 }
127 } 147 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/scripts/utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698