#26 Username in ssh url only when authenicated
Merged 7 years ago by pingou. Opened 7 years ago by pingou.

file modified
+6 -4
@@ -221,13 +221,15 @@ 

                    aria-expanded="false" aria-controls="moregiturls"

                    id="more_gits">more</a></span>{%endif%}</h5>

              <div>

+               {% if authenticated and g.repo_committer %}

                <div class="form-group">

                  <div class="input-group input-group-sm">

                    <div class="input-group-addon">SSH</div>

                    <input class="form-control" type="text" value="{{

-                     config.get('GIT_URL_SSH') }}{{ repo.fullname }}.git" readonly>

+                     git_url_ssh }}{{ repo.fullname }}.git" readonly>

                  </div>

                </div>

+               {% endif %}

                <div class="form-group">

                  <div class="input-group input-group-sm">

                    <div class="input-group-addon">GIT</div>
@@ -245,7 +247,7 @@ 

                        <div class="input-group input-group-sm">

                          <div class="input-group-addon">SSH</div>

                          <input class="form-control" type="text" value="{{

-                           config.get('GIT_URL_SSH') }}docs/{{ repo.fullname }}.git" readonly>

+                           git_url_ssh }}docs/{{ repo.fullname }}.git" readonly>

                        </div>

                      </div>

                    {% endif %}
@@ -265,7 +267,7 @@ 

                        <div class="input-group input-group-sm">

                          <div class="input-group-addon">SSH</div>

                          <input class="form-control" type="text" value="{{

-                           config.get('GIT_URL_SSH') }}tickets/{{ repo.fullname }}.git" readonly>

+                           git_url_ssh }}tickets/{{ repo.fullname }}.git" readonly>

                        </div>

                      </div>

                    {% endif %}
@@ -274,7 +276,7 @@ 

                      <div class="input-group input-group-sm">

                        <div class="input-group-addon">SSH</div>

                        <input class="form-control" type="text" value="{{

-                         config.get('GIT_URL_SSH') }}requests/{{ repo.fullname }}.git" readonly>

+                         git_url_ssh }}requests/{{ repo.fullname }}.git" readonly>

                      </div>

                    </div>

                  {% endif %}

no initial comment

@pingou looks good. You should perhaps consider doing the format(username=g.fas_user.username) part in the view, wrapped with a try except block in case the configuration doesn't have "{username}" in it. If it excepts, you can fallback to the old way. Once formatted, you can pass it on as a variable to your Jinja2 template.

@mprahl unlike %, .format() is much more resilient but I still managed to make it crash:

>>> ' foo {user}'.format(user='bar')
' foo bar'
>>> ' foo'.format(user='bar')
' foo'
>>> ' foo'.format('bar')
' foo'
>>> ' foo {user}'.format('bar')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    ' foo {user}'.format('bar')
KeyError: 'user'
>>> ' foo {}'.format(user='bar')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    ' foo {}'.format(user='bar')
IndexError: tuple index out of range

So I guess you're right

Adjusted here as well

rebased

7 years ago

Pull-Request has been merged by pingou

7 years ago
Metadata