From 81c82227351db7c73d67dbef46a8b1ff6458c732 Mon Sep 17 00:00:00 2001 From: gdits <1125155791@qq.com> Date: Wed, 3 Jun 2020 10:24:00 +0800 Subject: [PATCH 1/3] tee-update --- README.en.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.en.md b/README.en.md index ef22c86..1d34534 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 -- Gitee From 290f57d48c480c7c4f4cd30494e5206deb85a385 Mon Sep 17 00:00:00 2001 From: gdits <1125155791@qq.com> Date: Wed, 10 Jun 2020 18:36:57 +0800 Subject: [PATCH 2/3] add more --- _actions.html.haml | 6 +- diff_excerpt.js | 184 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+), 3 deletions(-) create mode 100644 diff_excerpt.js diff --git a/_actions.html.haml b/_actions.html.haml index 0dcf8df..96970b4 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 0000000..62b0f00 --- /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; +}()); -- Gitee From 1455cd11d53191b8f1fe2c88ae409befe9aa6257 Mon Sep 17 00:00:00 2001 From: gdits <1125155791@qq.com> Date: Wed, 10 Jun 2020 18:37:30 +0800 Subject: [PATCH 3/3] rm rb --- repository.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/repository.rb b/repository.rb index ea3ba28..59c9495 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 -- Gitee