Skip to content

Commit

Permalink
add simple reduced changelog for git changes
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Feb 12, 2017
1 parent a082e5e commit 9ee0a81
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
42 changes: 41 additions & 1 deletion app-src/scripts/main/global-services/git-s.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@
}
}

function createSimpleChangeLogForTask(updatedTask, oldTask) {
const changeLog = [];

if (updatedTask.title !== oldTask.title) {
changeLog.push(createChangelogEntry('title', updatedTask.title));
}
if (updatedTask.notes !== oldTask.notes) {
changeLog.push(createChangelogEntry('description', updatedTask.notes));
}

return changeLog;
}

function createChangelogEntry(changedField, changeToVal, author, date) {
return {
author: author,
items: [{
field: changedField,
toString: changeToVal
}],
created: date
};
}

// HELPER METHODS
// --------------
this.isGitTask = (task) => {
Expand Down Expand Up @@ -125,14 +149,30 @@
const issue = res.data;
const lastUpdate = moment(task.originalUpdated);
if (lastUpdate && moment(issue.originalUpdated).isAfter(lastUpdate)) {
// add simple changelog
if (!task.originalChangelog) {
task.originalChangelog = [];
}

task.originalChangelog = createSimpleChangeLogForTask(issue, task);

// extend task with new values
angular.extend(task, issue);
task.isUpdated = true;
taskIsUpdatedHandler(issue, task);

// also update comment list in the next step
this.getCommentListForIssue(task.originalId)
.then((res) => {
task.originalComments = res.data;
const comments = res.data;
if (comments.length !== task.originalComments.length) {
if (!task.originalChangelog) {
task.originalChangelog = [];
}

task.originalChangelog.push(createChangelogEntry('new comment added'));
}
task.originalComments = comments;
});
}
}, defer.reject)
Expand Down
5 changes: 3 additions & 2 deletions app-src/scripts/task-list/task-list-d.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@

<ul class="changelog">
<li ng-repeat="changelogEntry in task.originalChangelog">
<div><em>[{{ ::changelogEntry.author }}] {{ ::changelogEntry.created| amDateFormat:'Y.MM.DD HH:mm'}}: </em>
<div ng-if="changelogEntry.author">
<em>[{{ ::changelogEntry.author }}] {{ ::changelogEntry.created| amDateFormat:'Y.MM.DD HH:mm'}}: </em>
</div>
<div ng-repeat="change in changelogEntry.items">
<strong>"{{ ::change.field }}" changed to:</strong> {{ ::change.toString }}
<strong>{{ ::change.field }}</strong> <span ng-if="change.toString.length"><em>changed to:</em> {{ ::change.toString }}</span>
</div>
</li>
</ul>
Expand Down

0 comments on commit 9ee0a81

Please sign in to comment.