diff --git a/README.en.md b/README.en.md index ef22c86490dbaacabb6c35115199ccda31c5d08b..1d34534fbf4d0e30ce6eaf83d2b638af225fa044 100644 --- a/README.en.md +++ b/README.en.md @@ -6,7 +6,7 @@ bbb #### Software Architecture Software architecture description -#### Installation222222222222222 +#### Installation 1. xxxx 2. xxxx @@ -18,7 +18,7 @@ Software architecture description 2. xxxx 3. xxxx -#### Contribution +#### Contribution44444444444 1. Fork the repository 2. Create Feat_xxx branch diff --git a/_actions.html.haml b/_actions.html.haml index 0dcf8dfdcc05bea2df682c06fb66173b0b13d712..96970b4d4770b08f6bbcb15b78dcc0c33fb1b86b 100644 --- a/_actions.html.haml +++ b/_actions.html.haml @@ -6,11 +6,11 @@ - @is_item_readonly ||= is_upload_to_readonly?(@project, @ref, @blob.path) - if @project.online_edit_enabled && allowed_tree_edit? && on_branch && (!@project.block? || current_user.is_admin?) || can?(current_user, :create_lightweight_pr_allow_blank, @project) - if @is_item_readonly - = link_to t('bower.edit'), project_edit_blob_path(@project, @id), class: 'ui button edit-blob disabled-edit-readonly' + = link_to t('bower.edit'), project_blob_path(@project, @id), class: 'ui button edit-blob disabled-edit-readonly' - else - = link_to t('bower.edit'), project_edit_blob_path(@project, @id), class: 'ui button edit-blob', title: "#{t('project.branch.edit_only_login') if current_user.nil?}" + = link_to t('bower.edit'), project_blob_path(@project, @id), class: 'ui button edit-blob', title: "#{t('project.branch.edit_only_login') if current_user.nil?}" - else - = link_to t('bower.edit'), project_edit_blob_path(@project, @id), class: 'ui button disabled has_tooltip edit-blob', title: !on_branch ? t('project.branch.edit_on_branch') : t('project.branch.not_allow_edit') + = link_to t('bower.edit'), projectblob_path(@project, @id), class: 'ui button disabled has_tooltip edit-blob', title: !on_branch ? t('project.branch.edit_on_branch') : t('project.branch.not_allow_edit') - if @project.online_edit_enabled = link_to 'Web IDE', project_ide_path(@project, ref: @ref, blob: @blob.path), class: 'ui button web-ide', target: '_blank' if on_branch - if !@project.block? || current_user.is_admin? diff --git a/diff_excerpt.js b/diff_excerpt.js new file mode 100644 index 0000000000000000000000000000000000000000..62b0f001578ebeaaa74ca7a2c7f347007218ed5a --- /dev/null +++ b/diff_excerpt.js @@ -0,0 +1,184 @@ +/* eslint-disable vars-on-top */ +(function () { + var FETCH_COUNT = 20; + var IS_FETCHING = false; + var IS_PARALLEL_MODE = !!window.isParallelMode; + var fileTotalLineCounts = {}; + + jQuery.prototype.isFirstChild = function () { return $(this).is(':first-child'); } + jQuery.prototype.isLastChild = function () { return $(this).is(':last-child'); } + + function DiffExcerpt(diffFile) { + var $diffFile = $(diffFile); + + refreshExcerptOption($diffFile); + this.bindExcerptEvent($diffFile, { + url: $diffFile.data('url'), + filePath: $diffFile.data('file-path') + }); + } + + function getFileTotalLineCount($DOM) { + var $diffFile = $DOM.hasClass('diff-file') ? $DOM : $DOM.closest('.diff-file'); + if ($diffFile.length) { + var diffFileId = $diffFile.attr('id'); + if (!fileTotalLineCounts[diffFileId]) { + fileTotalLineCounts[diffFileId] = parseInt($diffFile.data('end-line-number'), 10); + } + return fileTotalLineCounts[diffFileId]; + } + return 0; + } + + function getExcerptHolderBothLine($excerptHolder) { + function _getLineNumber($lineHolder, defaultValue) { + return $lineHolder.length ? { + old: parseInt($lineHolder.find('.old_line [data-line-number]').data('line-number'), 10), + new: parseInt($lineHolder.find('.new_line [data-line-number]').data('line-number'), 10) + } : { + old: defaultValue, + new: defaultValue + } + } + + return { + prevLineNumber: _getLineNumber($excerptHolder.prev(), 0), + nextLineNumber: _getLineNumber($excerptHolder.next(), getFileTotalLineCount($excerptHolder)) + } + } + + function updateDiffHeader($excerptHolder) { + if ($excerptHolder.is(':not(:last-child)')) { + var $excerptLineContent = $excerptHolder.find('.line_content'); + + if (/@@ -\d+,\d+ \+\d+,\d+ @@/.test($excerptLineContent.text())) { + var bothLine = getExcerptHolderBothLine($excerptHolder); + var $untilLines = $excerptHolder.nextUntil('.excerpt-holder'); + var oldLinesCount = $untilLines.not(':has(.new)').length; + var newLinesCount = $untilLines.not(':has(.old)').length; + + $excerptLineContent.text( + '@@ -' + bothLine.nextLineNumber.old + ',' + oldLinesCount + ' +' + bothLine.nextLineNumber.new + ',' + newLinesCount + ' @@' + ); + } + } + } + + function initExcerptDOM(excerptArr) { + function _getDOM(diffClass, iconClass, title) { + return ( + '
' + + ' ' + + '
' + ); + } + + var placeholderDOM = ''; + if (excerptArr.indexOf('all') > -1) { + placeholderDOM = _getDOM('', 'icon-expand', window.gon.expandText.expandAll); + } else { + placeholderDOM = ( + (excerptArr.indexOf('down') > -1 ? _getDOM('down', 'icon-expand-down', window.gon.expandText.expandDown) : '') + + (excerptArr.indexOf('up') > -1 ? _getDOM('up', 'icon-expand-up', window.gon.expandText.expandUp) : '') + ); + } + if (IS_PARALLEL_MODE) { + return $('' + placeholderDOM + ''); + } else { + return $('' + placeholderDOM + ''); + } + } + + function refreshExcerptOption($diffFile) { + $diffFile.find('.excerpt-holder').each(function () { + var $excerptHolder = $(this); + var $tdPlaceholder = $excerptHolder.find('.placeholder_line'); + var bothLine = getExcerptHolderBothLine($excerptHolder); + + if ($excerptHolder.isFirstChild()) { + if (bothLine.nextLineNumber.new === 1) { + $tdPlaceholder.replaceWith($( + IS_PARALLEL_MODE ? + '...' : + '......' + )); + } else { + $tdPlaceholder.replaceWith(initExcerptDOM(['up'])); + } + } else if ($excerptHolder.isLastChild()) { + var fileTotalLineCount = getFileTotalLineCount($diffFile); + if ( + bothLine.prevLineNumber.old >= fileTotalLineCount || + bothLine.prevLineNumber.new >= fileTotalLineCount + ) { + $excerptHolder.remove(); + } else { + $tdPlaceholder.replaceWith(initExcerptDOM(['down'])); + } + } else { + var diffValue = bothLine.nextLineNumber.new - bothLine.prevLineNumber.new + if (diffValue <= 1) { + $excerptHolder.remove(); + } else if (diffValue > FETCH_COUNT) { + $tdPlaceholder.replaceWith(initExcerptDOM(['up', 'down'])); + } else { + $tdPlaceholder.replaceWith(initExcerptDOM(['all'])); + } + } + }); + } + + DiffExcerpt.prototype.bindExcerptEvent = function ($diffFile, data) { + $diffFile.find('.excerpt-holder').on('click', '.diff-excerpt', function () { + var $this = $(this); + var $excerptHolder = $this.closest('.line_holder'); + var isExcerptUp = $this.hasClass('up'); + + var bothLine = getExcerptHolderBothLine($excerptHolder); + var diffValue = bothLine.nextLineNumber.new - bothLine.prevLineNumber.new; + var lineNumber = isExcerptUp ? bothLine.nextLineNumber : bothLine.prevLineNumber; + + if ( + (isExcerptUp && $excerptHolder.isLastChild()) || + (!isExcerptUp && $excerptHolder.isFirstChild()) || + diffValue <= 0 + ) { + return; + } + + if (!$excerptHolder.isLastChild()) { + diffValue--; + } + + if (data.url && !IS_FETCHING) { + IS_FETCHING = true; + $.get(data.url, { + path: data.filePath, + direction: isExcerptUp ? 'up' : 'down', + view: IS_PARALLEL_MODE ? 'parallel' : '', + old_stn: lineNumber.old, + new_stn: lineNumber.new, + count: Math.min(diffValue, FETCH_COUNT) + }).done(function (res) { + if (res) { + var $responseDOM = $(res); + var $needUpdateHolder; + if (isExcerptUp) { + $excerptHolder.after($responseDOM); + $needUpdateHolder = $excerptHolder; + } else { + $excerptHolder.before($responseDOM); + $needUpdateHolder = $excerptHolder.prevAll('.excerpt-holder:eq(0)'); + } + refreshExcerptOption($diffFile); + updateDiffHeader($needUpdateHolder); + } + }).always(function () { + IS_FETCHING = false; + }); + } + }); + } + + window.DiffExcerpt = DiffExcerpt; +}()); diff --git a/repository.rb b/repository.rb index ea3ba28999b0cf6b2305e44120369e13bce0e11c..59c9495f4316a17d777821b4b85d0af6d4ccdc36 100644 --- a/repository.rb +++ b/repository.rb @@ -32,7 +32,6 @@ module Gitlab def archive(filename, compress_cmd, git_archive_cmd) File.open(filename, 'w') do |file| - # Create a pipe to act as the '|' in 'git archive ... | gzip' pipe_rd, pipe_wr = IO.pipe # Get the compression process ready to accept data from the read end # of the pipe