diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2016-10-18 19:56:13 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2016-10-18 19:56:13 +0300 |
commit | 2f7e1c0ead6b6bca102c674707ea8ee55ba55fa1 (patch) | |
tree | 3849a8cfd4e0cc8dcf9d8967f140c996e8e0fa6b /lib | |
parent | d25a1f305ac504662a74987b329e55e34ee8cd31 (diff) | |
parent | 88d988a2edb5c56e9cb475a1db51bf8bb399f437 (diff) |
Merge branch 'pipeline-emails' into 'master'
Add a new pipeline email service
## What does this MR do?
Add a new pipeline email service
## What are the relevant issue numbers?
Closes #3976
## Remaining tasks
* [x] Preserve `·` and ` `
* [x] Use XHTML 1.0
* [ ] Use the same layout (`app/views/layouts/notify.html.haml`)
* [ ] Digest or not (assets or public)
* [x] A similar email for succeeded pipeline
* [x] Plain text versions for both emails
## Screenshots (if relevant)
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6019#note_16594345
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
- [x] `PipelinesEmailService`
- [x] `SendPipelineNotificationService`
See merge request !6019
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/trace_reader.rb | 49 | ||||
-rw-r--r-- | lib/tasks/.gitkeep | 0 | ||||
-rw-r--r-- | lib/tasks/ci/.gitkeep | 0 |
3 files changed, 49 insertions, 0 deletions
diff --git a/lib/gitlab/ci/trace_reader.rb b/lib/gitlab/ci/trace_reader.rb new file mode 100644 index 00000000000..37e51536e8f --- /dev/null +++ b/lib/gitlab/ci/trace_reader.rb @@ -0,0 +1,49 @@ +module Gitlab + module Ci + # This was inspired from: http://stackoverflow.com/a/10219411/1520132 + class TraceReader + BUFFER_SIZE = 4096 + + attr_accessor :path, :buffer_size + + def initialize(new_path, buffer_size: BUFFER_SIZE) + self.path = new_path + self.buffer_size = Integer(buffer_size) + end + + def read(last_lines: nil) + if last_lines + read_last_lines(last_lines) + else + File.read(path) + end + end + + def read_last_lines(max_lines) + File.open(path) do |file| + chunks = [] + pos = lines = 0 + max = file.size + + # We want an extra line to make sure fist line has full contents + while lines <= max_lines && pos < max + pos += buffer_size + + buf = if pos <= max + file.seek(-pos, IO::SEEK_END) + file.read(buffer_size) + else # Reached the head, read only left + file.seek(0) + file.read(buffer_size - (pos - max)) + end + + lines += buf.count("\n") + chunks.unshift(buf) + end + + chunks.join.lines.last(max_lines).join + end + end + end + end +end diff --git a/lib/tasks/.gitkeep b/lib/tasks/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 --- a/lib/tasks/.gitkeep +++ /dev/null diff --git a/lib/tasks/ci/.gitkeep b/lib/tasks/ci/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 --- a/lib/tasks/ci/.gitkeep +++ /dev/null |