<commit_before><?php
/**
 * @var yii\web\View $this
 */
$this->title = yii::t('task', 'submit task title');
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use app\models\Project;
use app\models\Task;

?>
<style>
.tooltip-inner {
    max-width: none;
    white-space: nowrap;
    text-align:left;
}
</style>
<div class="box">
    <?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
      <div class="box-body">
        <?= $form->field($task, 'title')->label(yii::t('task', 'submit title'), ['class' => 'control-label bolder blue']) ?>
          <!-- 无trunk时，不需要查看所有分支-->
          <?php if ($nonTrunk) { ?>
              <input type="hidden" id="branch" class="form-control" name="Task[branch]" value="">
          <?php } else { ?>
              <!-- 分支选取 -->
              <div class="form-group">
                  <label class="control-label bolder blue">
                      <?= yii::t('task', 'select branches') ?>
                      <a class="show-tip icon-refresh green" href="javascript:;"></a>
                      <span class="tip"><?= yii::t('task', 'all branches') ?></span>
                      <i class="get-branch icon-spinner icon-spin orange bigger-125" style="display: none"></i>
                  </label>
                  <select name="Task[branch]" aria-hidden="true" tabindex="-1" id="branch" class="form-control select2 select2-hidden-accessible">
                      <?php if ($conf->repo_mode == Project::REPO_BRANCH) { ?>
                          <option value="trunk">trunk</option>
                      <?php } ?>
                  </select>
              </div>
          <?php } ?>

          <!-- 分支选取 end -->
          <div class="clearfix"></div>

          <?= $form->field($task, 'commit_id')->dropDownList([])
              ->label(yii::t('task', 'select branch').'<i class="get-history icon-spinner icon-spin orange bigger-125"></i>', ['class' => 'control-label bolder blue']) ?>

          <!-- 全量/增量 -->
          <div class="form-group">
              <label class="text-right bolder blue">
                  全量/增量:
              </label>
              <div id="transmission-full-ctl" class="radio" style="display: inline;" data-rel="tooltip" data-title="全量上线所有文件, 删除不在代码仓库中的文件" data-placement="right">
                  <label>
                      <input name="Task[file_transmission_mode]" value="<?= Task::FILE_TRANSMISSION_MODE_FULL ?>" checked="checked" type="radio" class="ace">
                      <span class="lbl"> 全量上线 </span>
                  </label>
              </div>

              <div id="transmission-part-ctl" class="radio" style="display: inline;" data-rel="tooltip" data-title="指定文件列表, 只发布指定的文件和目录" data-placement="right">
                  <label>
                      <input name="Task[file_transmission_mode]" value="<?= Task::FILE_TRANSMISSION_MODE_PART ?>" type="radio" class="ace">
                      <span class="lbl"> 指定文件 </span>
                  </label>
              </div>
          </div>
          <!-- 全量/增量 end -->

          <!-- 文件列表 -->
          <?= $form->field($task, 'file_list')
              ->textarea([
                  'rows'           => 12,
                  'placeholder'    => "index.php\nREADME.md\ndir*",
                  'data-html'      => 'true',
                  'data-placement' => 'top',
                  'data-rel'       => 'tooltip',
                  'data-title'     => yii::t('task', 'file list placeholder'),
                  'style'          => 'display: none',
              ])
              ->label(yii::t('task', 'file list'),
                  ['class' => 'control-label bolder blue', 'style' => 'display: none']) ?>

      </div><!-- /.box-body -->

      <div class="box-footer">
        <input type="submit" class="btn btn-primary" value="<?= yii::t('w', 'submit') ?>">
      </div>

    <!-- 错误提示-->
    <div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content" style="800px">
                <div class="modal-header">
                    <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        <?= yii::t('w', 'modal error title') ?>
                    </h4>
                </div>
                <div class="modal-body"></div>
            </div><!-- /.modal-content -->
        </div>

    </div>
    <!-- 错误提示-->

    <?php ActiveForm::end(); ?>
</div>

<script type="text/javascript">
    jQuery(function($) {
        $('[data-rel=tooltip]').tooltip({container:'body'});

        var projectId =  <?= (int)$_GET['projectId'] ?>;
        // 用户上次选择的分支作为转为分支
        var branch_name = 'pre_branch_' + projectId;
        var pre_branch = ace.cookie.get(branch_name);
        if (pre_branch) {
            var option = '<option value="' + pre_branch + '" selected>' + (pre_branch ? pre_branch : 'non-trunk') + '</option>';
            $('#branch').html(option);
            getCommitList();
        }

        // 无trunk时，直接获取commit log
        if (!$('#branch').val()) {
            getCommitList();
        }

        function getBranchList() {
            $('.get-branch').show();
            $('.tip').hide();
            $('.show-tip').hide();
            $.get("<?= Url::to('@web/walle/get-branch?projectId=') ?>" + projectId, function (data) {
                // 获取分支失败
                if (data.code) {
                    showError(data.msg);
                }
                var select = '';
                var nonTrunk = false;
                var count = 0;
                $.each(data.data, function (key, value) {
                    // 默认选中 trunk 主干
                    var checked = value.id == 'trunk' ? 'selected' : '';
                    select += '<option value="' + value.id + '"' + checked + '>' + value.message + '</option>';
                    nonTrunk = ++count == 1 && value.id == '';
                });
                if (nonTrunk) {
                    // 添加cookie记住最近使用的分支名字
                    ace.cookie.set(branch_name, '', 86400*30)
                }<commit_msg>消除重复获取commitList<commit_after><?php
/**
 * @var yii\web\View $this
 */
$this->title = yii::t('task', 'submit task title');
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use app\models\Project;
use app\models\Task;

?>
<style>
.tooltip-inner {
    max-width: none;
    white-space: nowrap;
    text-align:left;
}
</style>
<div class="box">
    <?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
      <div class="box-body">
        <?= $form->field($task, 'title')->label(yii::t('task', 'submit title'), ['class' => 'control-label bolder blue']) ?>
          <!-- 无trunk时，不需要查看所有分支-->
          <?php if ($nonTrunk) { ?>
              <input type="hidden" id="branch" class="form-control" name="Task[branch]" value="">
          <?php } else { ?>
              <!-- 分支选取 -->
              <div class="form-group">
                  <label class="control-label bolder blue">
                      <?= yii::t('task', 'select branches') ?>
                      <a class="show-tip icon-refresh green" href="javascript:;"></a>
                      <span class="tip"><?= yii::t('task', 'all branches') ?></span>
                      <i class="get-branch icon-spinner icon-spin orange bigger-125" style="display: none"></i>
                  </label>
                  <select name="Task[branch]" aria-hidden="true" tabindex="-1" id="branch" class="form-control select2 select2-hidden-accessible">
                      <?php if ($conf->repo_mode == Project::REPO_BRANCH) { ?>
                          <option value="trunk">trunk</option>
                      <?php } ?>
                  </select>
              </div>
          <?php } ?>

          <!-- 分支选取 end -->
          <div class="clearfix"></div>

          <?= $form->field($task, 'commit_id')->dropDownList([])
              ->label(yii::t('task', 'select branch').'<i class="get-history icon-spinner icon-spin orange bigger-125"></i>', ['class' => 'control-label bolder blue']) ?>

          <!-- 全量/增量 -->
          <div class="form-group">
              <label class="text-right bolder blue">
                  全量/增量:
              </label>
              <div id="transmission-full-ctl" class="radio" style="display: inline;" data-rel="tooltip" data-title="全量上线所有文件, 删除不在代码仓库中的文件" data-placement="right">
                  <label>
                      <input name="Task[file_transmission_mode]" value="<?= Task::FILE_TRANSMISSION_MODE_FULL ?>" checked="checked" type="radio" class="ace">
                      <span class="lbl"> 全量上线 </span>
                  </label>
              </div>

              <div id="transmission-part-ctl" class="radio" style="display: inline;" data-rel="tooltip" data-title="指定文件列表, 只发布指定的文件和目录" data-placement="right">
                  <label>
                      <input name="Task[file_transmission_mode]" value="<?= Task::FILE_TRANSMISSION_MODE_PART ?>" type="radio" class="ace">
                      <span class="lbl"> 指定文件 </span>
                  </label>
              </div>
          </div>
          <!-- 全量/增量 end -->

          <!-- 文件列表 -->
          <?= $form->field($task, 'file_list')
              ->textarea([
                  'rows'           => 12,
                  'placeholder'    => "index.php\nREADME.md\ndir*",
                  'data-html'      => 'true',
                  'data-placement' => 'top',
                  'data-rel'       => 'tooltip',
                  'data-title'     => yii::t('task', 'file list placeholder'),
                  'style'          => 'display: none',
              ])
              ->label(yii::t('task', 'file list'),
                  ['class' => 'control-label bolder blue', 'style' => 'display: none']) ?>

      </div><!-- /.box-body -->

      <div class="box-footer">
        <input type="submit" class="btn btn-primary" value="<?= yii::t('w', 'submit') ?>">
      </div>

    <!-- 错误提示-->
    <div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content" style="800px">
                <div class="modal-header">
                    <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        <?= yii::t('w', 'modal error title') ?>
                    </h4>
                </div>
                <div class="modal-body"></div>
            </div><!-- /.modal-content -->
        </div>

    </div>
    <!-- 错误提示-->

    <?php ActiveForm::end(); ?>
</div>

<script type="text/javascript">
    jQuery(function($) {
        $('[data-rel=tooltip]').tooltip({container:'body'});

        var projectId =  <?= (int)$_GET['projectId'] ?>;
        // 用户上次选择的分支作为转为分支
        var branch_name = 'pre_branch_' + projectId;
        var pre_branch = ace.cookie.get(branch_name);
        if (pre_branch) {
            var option = '<option value="' + pre_branch + '" selected>' + (pre_branch ? pre_branch : 'non-trunk') + '</option>';
            $('#branch').html(option);
        }

        function getBranchList() {
            $('.get-branch').show();
            $('.tip').hide();
            $('.show-tip').hide();
            $.get("<?= Url::to('@web/walle/get-branch?projectId=') ?>" + projectId, function (data) {
                // 获取分支失败
                if (data.code) {
                    showError(data.msg);
                }
                var select = '';
                var nonTrunk = false;
                var count = 0;
                $.each(data.data, function (key, value) {
                    // 默认选中 trunk 主干
                    var checked = value.id == 'trunk' ? 'selected' : '';
                    select += '<option value="' + value.id + '"' + checked + '>' + value.message + '</option>';
                    nonTrunk = ++count == 1 && value.id == '';
                });
                if (nonTrunk) {
                    // 添加cookie记住最近使用的分支名字
                    ace.cookie.set(branch_name, '', 86400*30)
                }
{'fraction_non_alphanumeric': 0.18607828952656538, 'fraction_numerical': 0.0041797283176593526, 'mean_word_length': 1.6149642707019756, 'pattern_counts': {'":': 0, '<': 191, '<?xml version=': 0, '>': 235, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5276238', 'n_tokens_mistral': 3823, 'n_tokens_neox': 3713, 'n_words': 686}