#31 Atomic CI results integration in pagure itself
Merged 8 years ago by pingou. Opened 8 years ago by pingou.

file added
+255
@@ -0,0 +1,255 @@ 

+ {% extends "repo_master.html" %}

+ 

+ {% block title %}Commit - {{

+     repo.namespace + '/' if repo.namespace }}{{ repo.name }} - {{ commitid }}{% endblock %}

+ {% set tag = "commit" %}

+ 

+ {% block repo %}

+ 

+ {% set split_message = commit.message.split('\n') %}

+ <div class="header">

+   <h4>

+     <span class="label label-default" title="{{ commitid }}">Commit {{ commitid|short }}</span>

+     <span>{{ split_message[0] }}</span>

+     <div class="pull-xs-right btn-group">

+       <a class="btn btn-secondary btn-sm" href="{{ url_for(

+         'view_raw_file',

+         repo=repo.name,

+         username=username,

+         namespace=repo.namespace,

+         identifier=commitid) }}" title="View as raw">raw</a>

+       <a class="btn btn-secondary btn-sm" href="{{ url_for(

+         'view_commit_patch',

+         repo=repo.name,

+         username=username,

+         namespace=repo.namespace,

+         commitid=commitid) }}">patch</a>

+       <a class="btn btn-secondary btn-sm" href="{{ url_for(

+         'view_tree', username=username, namespace=repo.namespace,

+         repo=repo.name, identifier=commitid) }}">tree</a>

+       {% if (commit.parents|length) == 1 %}

+       <a class="btn btn-secondary btn-sm" title={{commit.parents[0].oid.hex}} href="{{ url_for(

+         'view_commit',

+         repo=repo.name,

+         username=username,

+         namespace=repo.namespace,

+         commitid=commit.parents[0].oid.hex) }}">parent</a>

+       {% elif (commit.parents|length) > 1 %}

+       <div class="btn-group" role="group">

+         <button id="parentsDrop" type="button" class="btn btn-secondary btn-sm dropdown-toggle"

+             data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

+           parents

+         </button>

+         <div class="dropdown-menu dropdown-menu-right" aria-labelledby="parentsDrop">

+           {% for parent in commit.parents %}

+             <a class="dropdown-item" href="{{ url_for(

+                 'view_commit',

+                 repo=repo.name,

+                 username=username,

+                 namespace=repo.namespace,

+                 commitid=parent.oid.hex)

+             }}" class="commitid">{{ parent.oid.hex }}</a>

+           {% endfor %}

+         </div>

+       </div>

+       {% endif %}

+     </div>

+   </h4>

+   <h5 class="text-muted">

+     {% if (commit.author|author2user) == (commit.committer|author2user) %}

+       <a href="#" id="diff_list_link">{{ diff|count }} file{{'s' if (diff|count) > 1 }}</a>

+       {% if (commit.parents|length) == 1 %}

+         Authored and Committed by {{ commit.author|author2user|safe }}

+       {% else %}

+         Merged and Committed by {{ commit.author|author2user|safe }}

+       {% endif %}

+       <span data-toggle="tooltip" title="{{ commit.commit_time|format_ts }}">

+         {{ commit.commit_time|humanize }}

+       </span>

+     {% else %}

+       <a href="#" id="diff_list_link">{{ diff|count }} file{{'s' if (diff|count) > 1 }}</a>

+       {% if (commit.parents|length) == 1 %}

+         Authored by {{ commit.author|author2user|safe }}

+       {% else %}

+         Merged by {{ commit.author|author2user|safe }}

+       {% endif %}

+       <span data-toggle="tooltip" title="{{ commit.commit_time|format_ts }}">

+         {{ commit.commit_time|humanize }}

+       </span>,

+       Committed by {{ commit.committer|author2user|safe }}

+       <span data-toggle="tooltip" title="{{ commit.commit_time|format_ts }}">

+         {{ commit.commit_time|humanize }}

+       </span>,

+     {% endif %}

+   </h5>

+ </div>

+ <div id="msg_banner"></div>

+ 

+ <div class="list-group" id="diff_list" style="display:none;">

+   {% set filecount = 0 %}

+   {% for patch in diff %}

+       {% set filecount = filecount + 1 %}

+       {% if patch|hasattr('new_file_path') %}

+         <a class="list-group-item" href="#diff-file-{{filecount}}">

+           {{ patch.new_file_path|unicode}}

+       {% elif patch|hasattr('delta') %}

+         <a class="list-group-item" href="#diff-file-{{filecount}}">

+           {{ patch.delta.new_file.path|unicode }}

+       {% endif %}

+       <div class="pull-xs-right">

+         {% if not patch.is_binary  %}

+         {% if patch|hasattr('additions') %}

+         {% if (patch.additions + patch.deletions) %}

+           <span style="width: {{ (100.0 * patch.additions / (patch.additions + patch.deletions))|round|int }}%">

+             {% if patch.additions > 0 %}<span class="label label-success">+{{ patch.additions }}</span>{% endif %}

+             {% if patch.deletions > 0 %}<span class="label label-danger">-{{ patch.deletions }}</span>{% endif %}

+           </span>

+         {% endif %}

+         {% else %}

+         {% if (patch.line_stats[1] + patch.line_stats[2]) %}

+           <span style="width: {{ (100.0 * patch.line_stats[1] / (patch.line_stats[1] + patch.line_stats[2]))|round|int }}%">

+             {% if patch.line_stats[1] > 0 %}<span class="label label-success">+{{ patch.line_stats[1] }}</span>{% endif %}

+             {% if patch.line_stats[2] > 0 %}<span class="label label-danger">-{{ patch.line_stats[2] }}</span>{% endif %}

+           </span>

+         {% endif %}

+         {% endif %}

+         {% endif %}

+       </div>

+       {{ patch.new_file_path|unicode }}

+     </a>

+   {% endfor %}

+ </div>

+ 

+ <div class="m-y-1">

+     {% if split_message|length > 1 %}

+     <pre class="commit_message_body">

+         {% for message in split_message %}

+ {{ message }}

+         {% endfor %}

+     </pre>

+     {% endif %}

+ </div>

+ 

+ {% set filecount = 0 %}

+ {% for patch in diff %}

+   {% set filecount = filecount + 1 %}

+ <div class="card" id="diff-file-{{filecount}}">

+   <div class="card-header">

+     {% if patch|hasattr('new_file_path') %}

+       <a href="{{ url_for(

+           'view_file', username=username, namespace=repo.namespace,

+           repo=repo.name, identifier=commitid,

+           filename=patch.new_file_path) }}" title="View file as of {{ commitid|short }}">

+         {{  patch.new_file_path|unicode }}

+       </a>

+     {% elif patch|hasattr('delta') %}

+       <a href="{{ url_for(

+           'view_file', username=username, namespace=repo.namespace,

+           repo=repo.name, identifier=commitid,

+           filename=patch.delta.new_file.path) }}" title="View file as of {{ commitid|short }}">

+         {{  patch.delta.new_file.path|unicode }}

+       </a>

+     {% endif %}

+         {% if not patch.is_binary  %}

+           {% if patch|hasattr('additions') %}

+           {% if (patch.additions + patch.deletions) %}

+             <span style="width: {{ (100.0 * patch.additions / (patch.additions + patch.deletions))|round|int }}%">

+               {% if patch.additions > 0 %}<span class="label label-success">+{{ patch.additions }}</span> {% endif %}

+               {% if patch.deletions > 0 %}<span class="label label-danger">-{{ patch.deletions }}</span>{% endif %}

+             </span>

+           {% endif %}

+           {% else %}

+           {% if (patch.line_stats[1] + patch.line_stats[2]) %}

+             <span style="width: {{ (100.0 * patch.line_stats[1] / (patch.line_stats[1] + patch.line_stats[2]))|round|int }}%">

+               {% if patch.line_stats[1] > 0 %}<span class="label label-success">+{{ patch.line_stats[1] }}</span> {% endif %}

+               {% if patch.line_stats[2] > 0 %}<span class="label label-danger">-{{ patch.line_stats[2] }}</span>{% endif %}

+             </span>

+           {% endif %}

+           {% endif %}

+           {% endif %}

+   </div>

+ 

+     {% if patch.is_binary %}

+         <p class="noresult">Binary diffs cannot be rendered.</p>

+     {% else %}

+         {% autoescape false %}

+         {{ patch|patch_to_diff|html_diff}}

+         {% endautoescape %}

+     {% endif %}

+ </div>

+ 

+ {% endfor %}

+ 

+ {% endblock %}

+ 

+ 

+ 

+ {% block jscripts %}

+     {{ super() }}

+     <script type="text/javascript">

+       $(function(){

+         $('#diff_list_link').click(function(){

+           $('#diff_list').toggle();

+         });

+       });

+       $.ajax({

+         url: '{{ url_for("internal_ns.get_branches_of_commit") }}' ,

+         type: 'POST',

+         data: {

+           repo: "{{ repo.name }}",

+           repouser: "{{ repo.user.user if repo.is_fork else '' }}",

+           namespace: "{{ repo.namespace }}",

+           commit_id: "{{ commitid }}",

+           csrf_token: "{{ form.csrf_token.current_token }}",

+         },

+         dataType: 'json',

+         success: function(res) {

+             if (res.branches.length == 0){

+                 return;

+             }

+             var _br = '';

+             for (var i = 0; i < res.branches.length; ++i) {

+                 if (_br.length > 0){

+                     _br += ', ';

+                 }

+                 _br += res.branches[i]

+             }

+             var el = $('#diff-file-1');

+             if (!el){

+                 return;

+             }

+             el.before(

+                 '<div class=""><span class="oi" data-glyph="fork"></span> '

+                 + _br + '</div>');

+         }

+       });

+     {% if config.get('RESULTSDB_URL') %}

+       var _base_url = '{{ config.get("RESULTSDB_URL").rstrip("/") }}/api/v2.0/';

+       var _url = _base_url

+         + "results/latest?rev=" + '{{ commitid }}'

+         + "&repo=" + '{{ repo.name }}'

+         + "&namespace=" + '{{ repo.namespace }}'

+         + "&testcases=org.centos.prod.ci.pipeline.complete";

+       $.ajax({

+         url: _url ,

+         type: 'GET',

+         dataType: 'jsonp',

+         success: function(res) {

+           var el = $('#msg_banner');

+           ref_url = res.data[0]['ref_url'];

+           status = res.data[0]['outcome'];

+           var _lbl = 'label-danger';

+           if (status == 'PASSED') {

+             _lbl = 'label-success';

+           }

+           var html = '<div class="pull-xs-right">'

+             + '<a class="small label label-sm ' + _lbl + '" data-toggle="tooltip"'

+             + 'href="' + ref_url + '"'

+             + 'title="{{ commitid }} ' + status +' the Fedora Atomic CI pipeline">'

+             + status + ' Atomic CI</a></div>';

+           el.html(html);

+         }

+       });

+     {% endif %}

+     </script>

+ {% endblock %}

file added
+224
@@ -0,0 +1,224 @@ 

+ {% extends "repo_master.html" %}

+ 

+ {% from "_render_repo.html" import pagination_link %}

+ 

+ {% block title %}{{ select.capitalize() }} - {{

+     repo.namespace + '/' if repo.namespace }}{{ repo.name }}{% endblock %}

+ {% set tag = "home" %}

+ 

+ {% block header %}

+   {{ super() }}

+ <style>

+   .glyphicon.glyphicon-one-fine-dot:before {

+     content: "\25cf";

+     font-size: 1em;

+   }

+ </style>

+ {% endblock %}

+ 

+ {% block repo %}

+   <div class="row m-b-1">

+     {% if g.repo_obj and g.repo_obj.is_empty %}

+     <div class="col-md-12">

+       <div class="alert alert-info" role="alert">

+         <p>This repo is brand new!</p>

+         <p>There are no commits to this project yet</p>

+       </div>

+     </div>

+     {% else %}

+     <div class="col-sm-6">

+     <h3>

+       Commits <span class="label label-default"> {{number_of_commits}}</span>

+     </h3>

+     </div>

+ 

+     <div class="col-sm-6">

+       <div class="pull-xs-right">

+       <div class="button-label button-label-default">

+         {% if repo.is_fork %}

+         <span class="oi" data-glyph="fork"></span>

+         {{ repo.user.user }}/{{ repo.name }}

+         {% else %}

+         <span class="oi" data-glyph="document"></span> {{ repo.name }}

+         {% endif %}

+ 

+       </div>

+       {% if branchname %}

+         <div class="btn-group">

+           <button type="button" class="btn btn-secondary btn-sm dropdown-toggle"

+                   data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

+                   <span class="oi" data-glyph="random"> </span> {{ branchname }}

+           </button>

+           <div class="dropdown-menu dropdown-menu-right">

+             {% for branch in g.branches %}

+                 <a class="dropdown-item" href="{{ url_for(

+                     'view_commits',

+                     repo=repo.name,

+                     username=username,

+                     namespace=repo.namespace,

+                     branchname=branch) }}">

+                   {{ branch }}

+                 </a>

+             {% endfor %}

+           </div>

+         </div>

+       {% endif %}

+     </div>

+   </div>

+   </div>

+ 

+     {% if (diff_commits|count) > 0 and head %}

+     <div class="alert alert-info" role="alert">

+       This branch contains <a href="#" id="diff_commits_link">

+       {{ diff_commits|count }} commits</a> not in

+       {% if repo.is_fork %}

+         the upstream project

+         <span class="pr-toplabel">

+           <span class="oi" data-glyph="document"></span>

+           {{ repo.name }}

+           </span>

+       {% else %}

+         the main branch

+       {% endif %}

+       <span class="pr-toplabel">

+         <span class="oi" data-glyph="random"> </span>

+         {{head}}

+       </span>

+ 

+       {% if diff_commits and authenticated and head and

+         (repo.is_fork or repo.settings.get('pull_requests', True)) %}

+           <div id="request_pull" class="pull-xs-right">

+             <a class="btn btn-primary btn-sm"

+               href="{{ url_for('new_request_pull',

+                     repo=repo.name,

+                     username=username,

+                     namespace=repo.namespace,

+                     branch_to=head, branch_from=branchname or 'master') }}">

+               {% if g.repo_committer %}Create pull request{% else %}Compare{% endif %}

+             </a>

+           </div>

+       {% endif %}

+ 

+       <div id="diff_commits" class="list-group m-t-1" style="display:none;">

+         {% for diff_commit_full in diff_commits_full %}

+            <a href="{{ url_for('view_commit',

+                     repo=repo.name,

+                     username=username,

+                     namespace=repo.namespace,

+                     commitid=diff_commit_full.hex)

+               }}" class="list-group-item">

+               <h5>

+                 <strong>{{ diff_commit_full.message.split('\n')[0] }}</strong>

+                 <div class="pull-xs-right">

+                   <span class="commitdate"

+                         title="{{ diff_commit_full.commit_time|format_ts }}">

+                     {{ diff_commit_full.commit_time|humanize }}

+                   </span>

+                 </div>

+               </h5>

+               {{ diff_commit_full.author|author2avatar(20)|safe }}

+               {{ diff_commit_full.author.name }}

+               <div class="pull-xs-right">

+                 <span class="label label-default">

+                   {{ diff_commit_full.hex|short }}

+                 </span>

+               </div>

+             </a>

+         {% endfor %}

+       </div>

+     </div>

+     {% endif %}

+ 

+       <div class="list-group m-t-1">

+         {% for commit in last_commits %}

+           <div class="list-group-item{%

+                 if diff_commits and commit.oid.hex in diff_commits %} p-l-3{%

+                 endif %}" style="position:relative;">

+             {% if diff_commits and commit.oid.hex in diff_commits %}

+               <div title="This commit is not in the main branch of this Repo"

+                   style="position:absolute; left:0; top:0; padding:5px;

+                          padding-top:20px; height:100%; background:#eee;

+                          vertical-align:middle;">

+                 <span class="oi" data-glyph="arrow-thick-right"></span>

+               </div>

+             {% endif %}

+             <h5>

+               <a href="{{ url_for('view_commit',

+                     repo=repo.name,

+                     username=username,

+                     namespace=repo.namespace,

+                     commitid=commit.hex, branch=branchname) }}"

+                   class="notblue">

+                 <strong>{{ commit.message.split('\n')[0] }}</strong>

+                 <div class="pull-xs-right">

+                   <span class="commitdate"

+                         title="{{ commit.commit_time|format_ts }}">

+                     {{ commit.commit_time|humanize }}

+                   </span>

+                 </div>

+               </a>

+             </h5>

+               {{ commit.author|author2user_commits(

+                 link=url_for('view_commits',

+                     repo=repo.name,

+                     branchname=branchname,

+                     username=username,

+                     namespace=repo.namespace,

+                     author=commit.author.email),

+                 cssclass="notblue")|safe }}

+             <div class="pull-xs-right">

+               <span class="label label-default commithash" id="c_{{ commit.hex }}">

+                 {{ commit.hex|short }}

+               </span>

+             </div>

+           </div>

+         {% endfor %}

+       </div>

+ 

+       {{ pagination_link('page', g.page, total_page) }}

+ 

+     {% endif %}

+     </div>

+ {% endblock %}

+ 

+ {% block jscripts %}

+ {{ super() }}

+ <script type="text/javascript">

+   $(function(){

+     $('#diff_commits_link').click(function(){

+       $('#diff_commits').toggle();

+     });

+   });

+   {% if config.get('RESULTSDB_URL') %}

+     var _base_url = '{{ config.get("RESULTSDB_URL").rstrip("/") }}/api/v2.0/';

+     var _url = _base_url

+       + "results/latest?repo=" + '{{ repo.name }}'

+       + "&namespace=" + '{{ repo.namespace }}'

+       + "&testcases=org.centos.prod.ci.pipeline.complete";

+     var listItems = $(".commithash");

+     listItems.each(function(idx, li) {

+       var _id = $(li).attr('id');

+       var _h = _id.substring(2)

+       $.ajax({

+         url: _url + '&rev=' + _h,

+         type: 'GET',

+         dataType: 'jsonp',

+         success: function(res) {

+           var el = $(li);

+           ref_url = res.data[0]['ref_url'];

+           status = res.data[0]['outcome'];

+           var _lbl = 'red';

+           if (status == 'PASSED') {

+             _lbl = '#06ea10';

+           }

+           var html = '<a style="color:' + _lbl + '" data-toggle="tooltip"'

+             + 'href="' + ref_url + '"'

+             + 'title="{{ commitid }} ' + status +' the Fedora Atomic CI pipeline">'

+             + '<span class="glyphicon glyphicon-one-fine-dot"></span></a>';

+           el.after(html);

+         }

+       });

+     });

+   {% endif %}

+ </script>

+ {% endblock %}

no initial comment

The commits will probably be easier to review if taken one by one :)

Looks cool to me, though it might be nice to have some tests to assert all the if statements in the new template code.

Also, Pagure is 100% the right place to report CI results instead of Bodhi!

I think it would be preferable to use split_message here, or maybe message_parts

Add some whitespace around the | operator?
{{ commitid | short }}

Whitespace around operator |, and maybe parentheses to clarify intent regarding operator precedence of | vs ==

in other places, there are spaces between tag content: {{ commit.parents[0].oid.hex }}

whitespace around |, maybe parentheses again

maybe extra whitespace {{ parent.oid.hex }}

missing whitespace for consistency {% endif %}

consistent whitespace around |, maybe parentheses

several whitespace inconsistencies in the following section, I didn't mark them all
they can obfuscate intent, e.g. {{'s' if diff|count > 1 }} could be {{ 's' if diff | (count > 1) }}

Do we really want to continue the line here? If this is usually done in Pagure then ok, but I feel like this is something to avoid. You could just concatenate the strings.

1 new commit added

  • Adjust code style in the commits and commit templates
8 years ago

4 new commits added

  • Adjust code style in the commits and commit templates
  • Customize the commits.html template to show Atomic CI status
  • Customize the commit.html template to show Atomic CI status
  • Import the commit.html and commits.html templates from pagure
8 years ago

4 new commits added

  • Adjust code style in the commits and commit templates
  • Customize the commits.html template to show Atomic CI status
  • Customize the commit.html template to show Atomic CI status
  • Import the commit.html and commits.html templates from pagure
8 years ago

4 new commits added

  • Adjust code style in the commits and commit templates
  • Customize the commits.html template to show Atomic CI status
  • Customize the commit.html template to show Atomic CI status
  • Import the commit.html and commits.html templates from pagure
8 years ago

4 new commits added

  • Adjust code style in the commits and commit templates
  • Customize the commits.html template to show Atomic CI status
  • Customize the commit.html template to show Atomic CI status
  • Import the commit.html and commits.html templates from pagure
8 years ago

Looks good, and more consistent now. Thanks!

Thanks for the review! :)

Pull-Request has been merged by pingou

8 years ago
Metadata