Login

Tag "git"

Snippet List

Calculating Maintainability Index for a whole project

With this command you can calculate the maintainability index for your whole project. In your settings you have to add a dictionary called `RADON_MI_SETTINGS`. It could be like this: ```python RADON_MI_SETTINGS = { 'paths': ['projectname'], 'exclude': 'projectname/some_app/some_file.py', 'ignore': 'migrations,tests', } ``` I had to add following packages: ``` radon==3.0.1 progress==1.5 plotly==3.7.0 GitPython==2.1.11 ``` Following commands are available: * `python manage.py calculate_maintainability_index` Only display the maintainability index of the project. The average from every file is build by using the logical lines of code per file. * `python manage.py calculate_maintainability_index --init` Go through every commit filtered by their commit_message (is set to “bump version” currently) and calculate the maintainability index for the whole project. This creates a file with the history. * `python manage.py calculate_maintainability_index --showhistory` Display the history of the maintainability_index in a graph in your browser. * `python manage.py calculate_maintainability_index --commit` Calculate the current maintainability_index and append it to your history. Commit your edited history file. * `python manage.py calculate_maintainability_index --fail` Calculate the current maintainability_index and raise an Error, if it is lower than the last entry in your history. Useful for use in an automated pipeline. Hints: * radon has a problem with large lists and dictionaries. If you have a file with a list or dictionary with more than 100 entries, you should exclude it. * To initialize your history you should change the commitmessage filter to something, that suits your needs. Created by Martin Becker at [Jonas und der Wolf GmbH](https://www.jonasundderwolf.de)

  • django
  • command
  • git
  • maintainability
Read More

Git Revision Template Tag

This displays the short commit id from the current HEAD. Add this to your admin/base_site.html or any other template. {% block userlinks %} /&nbsp;HEAD: <span style="color:yellow">{% git_short_version %}</span> /&nbsp; {{ block.super }} {% endblock %}

  • git
Read More

Update applications

This snippet is based on 928. I've added the support to update a custom folder, using shell arguments. It requires the argparse module. You can install it with: pip install argparse Usage: # Updates repositories in the specified <folder path> # The default is the ./ folder update_repos --path <folder path> # List available options update_repos -h Alessandro Molari

  • update
  • applications
  • svn
  • git
  • baazar
  • mercurial
  • repositories
Read More

Git media cache busting tag

This tag appends the current git revision as a GET parameter to a media files so the web server can set an expires header far in the future. Your project must be structured such that MEDIA_ROOT/../.git exists. Usage: `<link rel="stylesheet" type="text/css" href="{% media myapp/css/base.css %}">`

  • cache
  • media
  • git
Read More

Use git log to give your app a revision

Put that stuff in your settings.py Then you can use the git log last date to make that your "revision number" assuming you don't use regular version release numbers. With it you can do something like: <div id="footer"> &copy; My Company &mdash; The Super App (revision {{ GIT_REVISION_DATE }}) </div> See if you like it

  • settings
  • subprocess
  • git
Read More

update-django: Update your django git branches.

This is the (revamped) bash script I use to keep my git branches up-to-date with SVN to make my life a lot easier, just save it in a text file and read the instructions at the top! Hope it's useful to somebody else than me ;)

  • bash
  • merge
  • update
  • svn
  • git
Read More

Git recent commits template tag

Requires [GitPython](http://gitorious.org/projects/git-python). Grabs the most recent commits to a Git repository, as defined in `settings.py`. Inspired by [Simon Willison](http://simonwillison.net)'s [about page](http://simonwillison.net/about/). **Example:** {% get_recent_commits 10 as commits %} <ul> {% for commit in commits reversed %} <li>{{ commit.commited_date }} - {{ commit.message }}</li> {% endfor %} </ul>

  • templatetag
  • git
Read More

Update All Apps to Latest Revision

This snippet is based on [#844](http://www.djangosnippets.org/snippets/844/ "#844") and [#892](http://www.djangosnippets.org/snippets/892/ "#892") and updates all apps in the current directory using hg, svn, git or bzr. Including subdirectories not under version control (subfolders to keep your stuff organized). For example: python/lib/ django-trunk/ django-0.96/ pydelicious/ (...) django-apps/ django-tagging/ django-pagination/ django-registration/ django-threadedcomments/ django-mptt/ (...) The script will iterate through all of your apps (in the current dir and also recursively in subdirs NOT under version control) and update them to the latest version. To run, simply execute: python update_apps.py in the desired parent folder. Just in case it could be useful: In my case I'm using MAC OS X. I have a folder full of miscellaneous scripts under my HOMEDIR, with this content: /Users/Dedaluz/bin/update_apps.py /Users/Dedaluz/bin/update_apps (this is a bash script) The update_apps script contains simply: #!/bin/bash python /Users/Dedaluz/bin/update_apps.py Then I put this folder in my path, so in my /HOMEDIR/.bash_profile I add this line export PATH=$PATH:$HOME/bin And I just can update from any parent folder just going there and typing: update_apps

  • script
  • update
  • svn
  • git
  • hg
  • bzr
Read More

Update All Apps to Latest Revision

This snippet is based on [#844](http://www.djangosnippets.org/snippets/844/) and updates all apps in the current directory using hg, svn, git or bzr.

  • update
  • svn
  • git
  • hg
  • bzr
Read More

Update All Apps to Latest Revision

A simple script that I have put in my Django applications directory to fetch the latest application code from git and svn. For example, your directory structure might look like so: django-apps/ django-tagging/ django-pagination/ django-registration/ django-threadedcomments/ django-mptt/ update_apps.py Where update_apps.py is the source of this snippet. To run, simply execute: # python update_apps.py And the script will iterate through all of your apps and update them to the latest version.

  • script
  • update
  • apps
  • project
  • svn
  • git
Read More

10 snippets posted so far.