mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Add apply-patch, basic revert and cherry-pick functionality (#17902)
This code adds a simple endpoint to apply patches to repositories and branches on gitea. This is then used along with the conflicting checking code in #18004 to provide a basic implementation of cherry-pick revert. Now because the buttons necessary for cherry-pick and revert have required us to create a dropdown next to the Browse Source button I've also implemented Create Branch and Create Tag operations. Fix #3880 Fix #17986 Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
		@@ -313,9 +313,22 @@ export function initGlobalButtons() {
 | 
			
		||||
    alert('Nothing to hide');
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  $('.show-modal.button').on('click', function () {
 | 
			
		||||
    $($(this).data('modal')).modal('show');
 | 
			
		||||
    const colorPickers = $($(this).data('modal')).find('.color-picker');
 | 
			
		||||
  $('.show-modal').on('click', function () {
 | 
			
		||||
    const modalDiv = $($(this).attr('data-modal'));
 | 
			
		||||
    for (const attrib of this.attributes) {
 | 
			
		||||
      if (!attrib.name.startsWith('data-modal-')) {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
      const id = attrib.name.substring(11);
 | 
			
		||||
      const target = modalDiv.find(`#${id}`);
 | 
			
		||||
      if (target.is('input')) {
 | 
			
		||||
        target.val(attrib.value);
 | 
			
		||||
      } else {
 | 
			
		||||
        target.text(attrib.value);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    modalDiv.modal('show');
 | 
			
		||||
    const colorPickers = $($(this).attr('data-modal')).find('.color-picker');
 | 
			
		||||
    if (colorPickers.length > 0) {
 | 
			
		||||
      initCompColorPicker();
 | 
			
		||||
    }
 | 
			
		||||
@@ -323,10 +336,10 @@ export function initGlobalButtons() {
 | 
			
		||||
 | 
			
		||||
  $('.delete-post.button').on('click', function () {
 | 
			
		||||
    const $this = $(this);
 | 
			
		||||
    $.post($this.data('request-url'), {
 | 
			
		||||
    $.post($this.attr('data-request-url'), {
 | 
			
		||||
      _csrf: csrfToken
 | 
			
		||||
    }).done(() => {
 | 
			
		||||
      window.location.href = $this.data('done-url');
 | 
			
		||||
      window.location.href = $this.attr('data-done-url');
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,18 @@
 | 
			
		||||
import $ from 'jquery';
 | 
			
		||||
 | 
			
		||||
export function initRepoBranchButton() {
 | 
			
		||||
  $('.show-create-branch-modal.button').on('click', function () {
 | 
			
		||||
    $('#create-branch-form')[0].action = $('#create-branch-form').data('base-action') + $(this).data('branch-from-urlcomponent');
 | 
			
		||||
    $('#modal-create-branch-from-span').text($(this).data('branch-from'));
 | 
			
		||||
    $($(this).data('modal')).modal('show');
 | 
			
		||||
  $('.show-create-branch-modal').on('click', function () {
 | 
			
		||||
    let modalFormName = $(this).attr('data-modal-form');
 | 
			
		||||
    if (!modalFormName) {
 | 
			
		||||
      modalFormName = '#create-branch-form';
 | 
			
		||||
    }
 | 
			
		||||
    $(modalFormName)[0].action = $(modalFormName).attr('data-base-action') + $(this).attr('data-branch-from-urlcomponent');
 | 
			
		||||
    let fromSpanName = $(this).attr('data-modal-from-span');
 | 
			
		||||
    if (!fromSpanName) {
 | 
			
		||||
      fromSpanName = '#modal-create-branch-from-span';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $(fromSpanName).text($(this).attr('data-branch-from'));
 | 
			
		||||
    $($(this).attr('data-modal')).modal('show');
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -436,7 +436,7 @@ export function initRepository() {
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  // File list and commits
 | 
			
		||||
  if ($('.repository.file.list').length > 0 ||
 | 
			
		||||
  if ($('.repository.file.list').length > 0 || $('.branch-dropdown').length > 0 ||
 | 
			
		||||
    $('.repository.commits').length > 0 || $('.repository.release').length > 0) {
 | 
			
		||||
    initRepoBranchTagDropdown('.choose.reference .dropdown');
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user