Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies #943

Merged
merged 16 commits into from
Apr 20, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Choose the repo that matches the login name, if it exists
  • Loading branch information
dereklieu committed Apr 19, 2016
commit 01fb4175dd3eefa0c8a79e5aabcb3259f356321d
18 changes: 17 additions & 1 deletion app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,23 @@ module.exports = Backbone.Router.extend({
this.users.add(user);
}

var repo = user.repos.findWhere({ name: repoName });
// If user has access to repos with the same name,
// use the repo that matches the login/url, if available.
// https://github.com/prose/prose/issues/939
var repos = user.repos.filter(function (model) {
return model.get('name') === repoName;
});
var repo;
if (repos.length === 1) {
repo = repos[0];
} else if (repos.length > 1) {
// Returns false if there isn't a repo with a matching login.
// We're fine with that since _.isUndefined(false) === true
repo = repos.find(function (model) {
return model.get('owner').login === login;
});
}

if (_.isUndefined(repo)) {
repo = new Repo({
name: repoName,
Expand Down