fix: pulling from wrong repository by getting git settings each time #55

This commit is contained in:
Johannes Millan 2018-02-19 18:40:22 +01:00
parent b3cc7f8e5d
commit 0c6227a99e
8 changed files with 40 additions and 19 deletions

View file

@ -81,7 +81,7 @@
git: {
isShowIssuesFromGit: false,
isAutoImportToBacklog: false,
repo: undefined,
repo: '',
projectDir: undefined,
prPrefix: 'Check PR: '
},

View file

@ -43,7 +43,7 @@
// add new git tasks
Git.checkForNewAndAddToBacklog();
if (Git.isSufficientSettings() && $rootScope.r.git.isShowIssuesFromGit) {
if (Git.isRepoConfigured() && $rootScope.r.git.isShowIssuesFromGit) {
Git.getIssueList()
.then((res) => {
vm.taskSuggestions = vm.taskSuggestions.concat(res.data);

View file

@ -8,7 +8,7 @@
.
</p>
<p>If <strong>Jira integration</strong> is enabled (you can enable it on the <a class="md-accent"
ui-sref="settings">
ui-sref="xxxxxxxxxxxxxxxxxxxxx">
<ng-md-icon icon="settings"></ng-md-icon>
settings</a> page) you can use the input the top also for importing tasks from Jira. Just enter the issue number or the issue summary and select the issue you from the auto suggestions. You can
<strong>identify a successfully imported Jira issue by the link icon
@ -20,7 +20,7 @@
<ng-md-icon icon="my_library_books"></ng-md-icon>
meant to store tasks for later use below the list for your todays tasks. You can move tasks via drag and drop between the two lists. Or use the globally
<a class="md-accent"
ui-sref="settings">
ui-sref="xxxxxxxxxxxxxxxxxxxxx">
<ng-md-icon icon="settings"></ng-md-icon>
configurable keyboard shortcuts</a>.
</p>

View file

@ -9,7 +9,7 @@
<p>There are also several other <strong>keyboard shortcuts</strong> available. Check them out in the
<a class="md-accent"
ui-sref="settings">
ui-sref="xxxxxxxxxxxxxxxxxxxxx">
<ng-md-icon icon="settings"></ng-md-icon>
settings section</a>.
</p>

View file

@ -17,7 +17,7 @@
<div class="md-dialog-content">
<p>Happy to see you try out Super Productivity!</p>
<p>After familiarizing you with the basic functionality, you might want head over to
<a ui-sref="settings"
<a ui-sref="xxxxxxxxxxxxxxxxxxxxx"
ng-click="vm.cancel()"
class="md-accent">
<ng-md-icon icon="settings"></ng-md-icon>

View file

@ -86,7 +86,7 @@
<md-button class="md-icon-button"
aria-label="Settings"
ui-sref-active="md-raised"
ui-sref="settings">
ui-sref="xxxxxxxxxxxxxxxxxxxxx">
<md-tooltip md-direction="bottom">
Go to settings
</md-tooltip>

View file

@ -17,7 +17,7 @@
function Git($http, $rootScope, $injector, $q, Notifier, SimpleToast) {
const TYPE = 'GITHUB';
const BASE_URL = 'https://api.github.com/';
const settings = $rootScope.r && $rootScope.r.git;
const that = this;
// PRIVATE HELPER FUNCTIONS
// ------------------------
@ -30,7 +30,7 @@
}
if (issue.pull_request) {
title = `${settings.prPrefix} #${issue.number}: ${issue.title}`;
title = `${that.getSettings().prPrefix} #${issue.number}: ${issue.title}`;
} else {
title = `#${issue.number} ${issue.title}`;
}
@ -117,27 +117,48 @@
return task && task.originalId && task.originalType === TYPE;
};
this.isRepoConfigured = () => {
const settings = this.getSettings();
return settings && settings.repo && settings.repo.trim() !== '';
};
this.getSettings = () => {
return $rootScope.r && $rootScope.r.git;
};
// API METHODS
// -----------
this.getLatestSpRelease= () => {
this.getLatestSpRelease = () => {
const SP_REPO_STR = BASE_URL + 'repos/johannesjo/super-productivity/releases/latest';
return $http.get(SP_REPO_STR);
};
this.getIssueList = () => {
return $http.get(BASE_URL + 'repos/' + settings.repo + '/issues', {
if (!this.isRepoConfigured()) {
return $q.reject();
}
return $http.get(BASE_URL + 'repos/' + this.getSettings().repo + '/issues', {
transformResponse: [transformIssueList]
});
};
this.getCommentListForIssue = (issueNumber) => {
return $http.get(BASE_URL + 'repos/' + settings.repo + '/issues/' + issueNumber + '/comments', {
if (!this.isRepoConfigured()) {
return $q.reject();
}
return $http.get(BASE_URL + 'repos/' + this.getSettings().repo + '/issues/' + issueNumber + '/comments', {
transformResponse: [transformComments]
});
};
this.getIssueById = (issueNumber) => {
return $http.get(BASE_URL + 'repos/' + settings.repo + '/issues/' + issueNumber, {
if (!this.isRepoConfigured()) {
return $q.reject();
}
return $http.get(BASE_URL + 'repos/' + this.getSettings().repo + '/issues/' + issueNumber, {
transformResponse: [transformIssue]
});
};
@ -145,6 +166,10 @@
// COMPLEXER WRAPPER METHODS
// -------------------------
this.checkAndUpdateTasks = (tasks) => {
if (!this.isRepoConfigured()) {
return $q.reject();
}
const TasksUtil = $injector.get('TasksUtil');
const defer = $q.defer();
@ -196,14 +221,10 @@
return defer.promise;
};
this.isSufficientSettings = () => {
return $rootScope.r.git && $rootScope.r.git.repo;
};
this.checkForNewAndAddToBacklog = () => {
const Tasks = $injector.get('Tasks');
if (this.isSufficientSettings() && $rootScope.r.git.isAutoImportToBacklog) {
if (this.isRepoConfigured() && $rootScope.r.git.isAutoImportToBacklog) {
this.getIssueList()
.then((res) => {
const issues = res.data;

View file

@ -28,7 +28,7 @@
url: '/work-view',
template: '<work-view></work-view>'
})
.state('settings', {
.state('xxxxxxxxxxxxxxxxxxxxx', {
url: '/settings',
controller: 'SettingsCtrl',
controllerAs: 'vm',