Skip to content

Commit

Permalink
Merge pull request #893 from codingtwinky/874
Browse files Browse the repository at this point in the history
Fix cached promised values not resolving properly in some platforms.  #874 #878 #887
  • Loading branch information
jung-kim authored Apr 3, 2017
2 parents 352a7d2 + 0268018 commit 35da6de
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
Use the following format for additions: ` - VERSION: [feature/patch (if applicable)] Short description of change. Links to relevant issues/PRs.`

- 1.1.12:
- Retain commit messages when commit fails [#882](https://github.com/FredrikNoren/ungit/pull/882)
- Fix rare edge case where remote node is gone during reset op.
- rescursively resolve all promises before caching them. [#878](https://github.com/FredrikNoren/ungit/pull/878)
- 1.1.11:
- Fix cli arguments [#871](https://github.com/FredrikNoren/ungit/pull/871)
- Stop if ~/.ungitrc contains syntax error
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Known issues
* If you're running MacOSX Mavericks and Ungit crashes after a few seconds; try updating npm and node. See [#259](https://github.com/FredrikNoren/ungit/issues/259) and [#249](https://github.com/FredrikNoren/ungit/issues/249) for details.
* Ubuntu users may have trouble installing because the node executable is named differently on Ubuntu, see [#401](https://github.com/FredrikNoren/ungit/issues/401) for details.
* Debian Wheezy's supported git and nodejs packages are too old, therefore download newest [git](https://github.com/git/git/releases) and [nodejs](https://nodejs.org/download/) tarballs and [build from source](http://www.control-escape.com/linux/lx-swinstall-tar.html).
* Adblocker may block Ungit! Some ad blockers, such as [Adblock plus](https://adblockplus.org) and [uBlock](https://www.ublock.org/), donn't like localhost api calls and assume that it is a cross domain attack. Please whitelist `{localhost|127.0.0.1|$UngitURL}:{ungit port number}`. [#887](https://github.com/FredrikNoren/ungit/issues/887) [#892](https://github.com/FredrikNoren/ungit/issues/892)

Changelog
---------
Expand Down
3 changes: 2 additions & 1 deletion components/graph/git-graph-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ GraphActions.Reset = function(graph, node) {
var context = self.graph.currentActionContext();
if (context.node() != self.node) return false;
var remoteRef = context.getRemoteRef(self.graph.currentRemote());
return remoteRef &&
return remoteRef && remoteRef.node() &&
context && context.node() &&
remoteRef.node() != context.node() &&
remoteRef.node().date < context.node().date;
});
Expand Down
6 changes: 2 additions & 4 deletions components/staging/staging.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,9 @@ StagingViewModel.prototype.commit = function() {
if (this.commitMessageBody()) commitMessage += '\n\n' + this.commitMessageBody();

this.server.postPromise('/commit', { path: this.repoPath(), message: commitMessage, files: files, amend: this.amend() })
.then(function() { self.resetMessages(); })
.catch(function() {})
.finally(function() {
self.committingProgressBar.stop();
self.resetMessages();
});
.finally(function() { self.committingProgressBar.stop(); });
}
StagingViewModel.prototype.conflictResolution = function(apiPath, progressBar) {
var self = this;
Expand Down
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ungit",
"author": "Fredrik Norén <fredrik.jw.noren@gmail.com>",
"description": "Git made easy",
"version": "1.1.11",
"version": "1.1.12",
"ungitPluginApiVersion": "0.2.0",
"scripts": {
"start": "node ./bin/ungit",
Expand All @@ -25,52 +25,52 @@
"cookie-parser": "~1.4.3",
"crossroads": "~0.12.2",
"diff2html": "^2.3.0",
"express": "~4.14.0",
"express-session": "~1.14.2",
"express": "~4.15.2",
"express-session": "~1.15.2",
"forever-monitor": "~1.1.0",
"getmac": "~1.2.1",
"hasher": "~1.2.0",
"ignore": "~3.2.0",
"ignore": "~3.2.6",
"keen.io": "~0.1.3",
"knockout": "~3.4.1",
"knockout": "~3.4.2",
"lodash": "~4.17.4",
"mkdirp": "~0.5.1",
"moment": "~2.17.1",
"moment": "~2.18.1",
"node-cache": "~4.1.1",
"npm": "~4.1.1",
"npm-registry-client": "~7.4.5",
"npm": "~4.5.0",
"npm-registry-client": "~8.1.0",
"octicons": "~3.5.0",
"open": "~0.0.5",
"os-homedir": "~1.0.2",
"passport": "~0.3.2",
"passport-local": "~1.0.0",
"raven": "~1.1.1",
"rc": "~1.1.6",
"rimraf": "~2.5.4",
"raven": "~1.2.0",
"rc": "~1.1.7",
"rimraf": "~2.6.1",
"semver": "~5.3.0",
"serve-static": "~1.11.1",
"serve-static": "~1.12.1",
"signals": "~1.0.0",
"snapsvg": "~0.4.0",
"socket.io": "~1.7.2",
"snapsvg": "~0.5.1",
"socket.io": "~1.7.3",
"superagent": "^0.21.0",
"temp": "~0.8.3",
"winston": "~2.3.0",
"yargs": "~6.6.0"
"winston": "~2.3.1",
"yargs": "~7.0.2"
},
"devDependencies": {
"ansi-color": "~0.2.1",
"babel-preset-es2015": "~6.18.0",
"babel-preset-stage-0": "~6.16.0",
"browserify": "~13.1.1",
"electron-packager": "~8.4.0",
"babel-preset-es2015": "~6.24.0",
"babel-preset-stage-0": "~6.22.0",
"browserify": "~14.1.0",
"electron-packager": "~8.6.0",
"expect.js": "~0.3.1",
"grunt": "~1.0.1",
"grunt-babel": "~6.0.0",
"grunt-contrib-clean": "~1.0.0",
"grunt-contrib-copy": "~1.0.0",
"grunt-contrib-imagemin": "~1.0.1",
"grunt-contrib-jshint": "~1.1.0",
"grunt-contrib-less": "~1.4.0",
"grunt-contrib-less": "~1.4.1",
"grunt-contrib-watch": "~1.0.0",
"grunt-image-embed": "0.3.3",
"grunt-lineending": "~1.0.0",
Expand Down
18 changes: 16 additions & 2 deletions source/utils/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,29 @@ cache.resolveFunc = (key) => {
return cache.getAsync(key) // Cant do `cache.getAsync(key, true)` due to `get` argument ordering...
.catch({ errorcode: "ENOTFOUND" }, (e) => {
if (!funcMap[key]) throw e; // func associated with key is not found, throw not found error
const result = funcMap[key].func(); // func is found, resolve, set with TTL and return result
return (result.then ? result : Bluebird.resolve(result))
return getHardValue(funcMap[key].func()) // func is found, resolve, set with TTL and return result
.then((r) => {
return cache.setAsync(key, r, funcMap[key].ttl)
.then(() => { return r; })
});
});
}

/**
* @function getHardValue
* @description In Linux, or certain settings, it seems that cached promises
* are not able to resolved and we need to cache raw result of promieses.
* @param {prom} - raw value or promise to be returned or resolved
* @param {promise} - a promise where next "then" will result in raw value.
*/
const getHardValue = (prom) => {
if (prom.then) {
return prom.then(getHardValue);
} else {
return Bluebird.resolve(prom);
}
}

/**
* @function registerFunc
* @description Register a function to cache it's result. If same key exists, key is deregistered and registered again.
Expand Down

0 comments on commit 35da6de

Please sign in to comment.