简体   繁体   English

如何在Bitbucket中的拉取请求中解决缩进/对齐问题?

[英]How do I fix indentation/alignment in my pull request in Bitbucket?

I have written a small piece of JavaScript code (not allowed to share code). 我已经写了一小段JavaScript代码(不允许共享代码)。 The code is aligned perfectly in text editor ( Sublime ) but in the pull request it is distorted. 该代码在文本编辑器( Sublime )中完美对齐,但在pull请求中却被扭曲了。 I tried to solve this but failed. 我试图解决此问题,但失败了。

I tried to save each line but the result in pull request in still same. 我试图保存每一行,但是在拉取请求中的结果仍然相同。 In SourceTree the indentation is correct before I push the code to the repository but after the push is successful the alignment dies. SourceTree ,在将代码推送到存储库之前,缩进是正确的,但是在推送成功之后,对齐方式就消失了。

Please forgive if this is a stupid question to ask to the developer community. 如果这是一个愚蠢的问题,请原谅给开发者社区。

Sample code 样例代码

$(document).ready(function()
{
    var validate = $("#formId").validate(
                   {
                       debug : true,
                       rules : {
                            Name : {
                                required : true
                            }
                       },
                       messages : {
                            Name: {
                                required : "Name is required"
                            }
                       },
                       onfocusout : false,
                       invalildHandler : function (form, validator)
                       {
                           var errors = validator.numberofInvalids();
                           if(errors)
                           {
                               validator.errorList[0].element.focus();
                           }
                        }
                    });
})

So this is how it is actually supposed to be (above code) but in the pull request it comes something like this 所以这实际上是(上面的代码)应该是这样,但是在pull request却是这样的

$(document).ready(function()
{
    var validate = $("#formId").validate(
                               {
                                   debug : true,
                                   rules : {
                                        Name : {
                                            required : true
                                   }
                               },
                                   messages : {
                                        Name : {
                                            required : "Name is required"
                                   }
                               },
                       onfocusout : false,
                       invalildHandler : function (form, validator)
                          {
                                   var errors = validator.numberofInvalids();
                                   if(errors)
                                   {
                                      validator.errorList[0].element.focus();
                                   }
                           }
                              });
})

I wonder if it'd figure out the problem, but hope you'd make a try anyway. 我想知道是否可以解决问题,但还是希望您能尝试一下。

  1. Download the conflicted target .js file from Bitbucket . Bitbucket下载冲突的目标.js文件。 (It doesn't matter whether it's a js file or not.) It's easy to make a file download if you open it as a raw status. (无论它是否是js文件都没有关系。)如果以raw状态打开文件,则很容易进行文件下载。
  2. Replace your local original file with that one. 用该文件替换您的本地原始文件。 It means you're going to get rid of confliction from your local side. 这意味着您将摆脱本地冲突
  3. Make a commit to remote Bitbucket repo by git push -u origin [your_branch] . 通过git push -u origin [your_branch]提交到远程Bitbucket存储库。 If your branch is not the master one, make a PR (pull request) and update your local branches syncing with remote ones. 如果您的分支机构不是分支机构,则进行PR (拉动请求)并更新与远程分支机构同步的本地分支机构。
  4. Now you can recover your own indentation/alignment style on your favorite editor as you wish! 现在,您可以根据需要在自己喜欢的编辑器上恢复自己的缩进/对齐样式! (local edit) (本地编辑)
  5. Finally, make a commit to Bitbucket again. 最后,再次提交Bitbucket

To make a long story short, you can apply your own indentation after Git conflicts would get fixed. 长话短说,您可以在Git冲突解决后应用您自己的缩进。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM