How to use lookatgit

From FedoraProject

(Difference between revisions)
Jump to: navigation, search
(syntax fix)
(a few more overview details, renaming to overview)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
== Summary ==
+
== Overview ==
  
 
The 'lookatgit' program parses git repositories for information about who committed what, how much, when, what was removed, and what the impact of all this has been on the repository.
 
The 'lookatgit' program parses git repositories for information about who committed what, how much, when, what was removed, and what the impact of all this has been on the repository.
Line 6: Line 6:
  
 
It is written in Scala, compiled by the <code>scalac</code> compiler that uses a Java runtime.
 
It is written in Scala, compiled by the <code>scalac</code> compiler that uses a Java runtime.
 +
 +
The Scala code wraps a few 'git' commands (git show, git log), then processes the output. Any language good at text processing could be used; the original author was playing with a new language while solving a new problem.
 +
 +
The Scala compiler 'scalac' builds the *.scala files in to a multiple *.class files.
 +
 +
The Scala runtime, 'scala', uses the configured JVM.
  
 
== How to obtain and install ==
 
== How to obtain and install ==
Line 47: Line 53:
 
</pre>
 
</pre>
  
 +
== Making it work ==
 +
 +
Ideally, add a <code>new-target</code> to the makefile that points at a codebase that you have cloned locally, then run the build:
 +
 +
<pre>
 +
make compile new-target
 +
</pre>
 +
 +
=== Problems ===
 +
 +
* Make sure you are running the latest Scala from upstream, even if it means using the tarball and putting it at <code>/opt/scala</code>.
 +
* Fedora 11 or later?  It's suppose to work on those platforms.
 +
 +
=== Solutions ===
 +
 +
* Adding debug and print commands: <code>System.out.println</code> and <code>System.err.println</code>.
 +
** For instance, in the code:
 +
<pre>System.err.println("Processing " + commit_ttl + " commits, this may take a while...")</pre>
 +
* Some tips from 'lookatgit' original author:
 +
** It is likely hung somehow.  The code is executing things via Runtime.getRuntime() ... a side effect of Scala using the JVM is it is bad at executing processes. There is a requirement to consume pending input or it will hang.
  
 
[[Category:How to]]
 
[[Category:How to]]
 
[[Category:Draft documentation]]
 
[[Category:Draft documentation]]

Latest revision as of 18:31, 13 November 2009

Contents

[edit] Overview

The 'lookatgit' program parses git repositories for information about who committed what, how much, when, what was removed, and what the impact of all this has been on the repository.

The upstream for 'lookatgit' is at http://github.com/mpdehaan/lookatgit.

It is written in Scala, compiled by the scalac compiler that uses a Java runtime.

The Scala code wraps a few 'git' commands (git show, git log), then processes the output. Any language good at text processing could be used; the original author was playing with a new language while solving a new problem.

The Scala compiler 'scalac' builds the *.scala files in to a multiple *.class files.

The Scala runtime, 'scala', uses the configured JVM.

[edit] How to obtain and install

These instructions recommend cloning the git repository and working from a local clone. You can obtain a tarball or zip file, if you wish. The effect is the same, but the git clone allows you to interact with the upstream if you need.

  1. Obtain the 'lookatgit' source code: git clone git://github.com/mpdehaan/lookatgit.git
    • If use github.com, you can use the fork command to make your own fork within github.com. The use the clone command on your own fork, instead of the main upstream tree: git clone git://github.com/YOURUSERNAME/lookatgit.git
  2. Install the scala and java-1.6.0-openjdk packages: sudo yum install scala java-1.6.0-openjdk
    • The 'lookatgit' README says to use the Scala upstream release directly. The Makefile for 'lookatgit' is hard-coded to seek the Scala binaries on that path. If you choose to follow this method, do not make changes to the Makefile.
  3. Edit the /path/to/src/lookatgit/Makefile. Below is what the Makefile looks like in the upstream source. Change the path to the Scala compiler to /usr/bin/scalac and the Scala runtime to /usr/bin/scala
  4. Edit the Makefile to include a new target for your chosen git repository. The git repository must exist locally:
    1. cd ~/git/
    2. git clone git://example.com/example.git
    3. Edit Makefile to include this target:
      • example:
      • 	/usr/bin/scala -classpath . App ~/git/example
  5. Compile the Scala code into class files: make compile
  6. Run the application on the git repository: make example

[edit] Makefile

Here is what the upstream Makefile looks like in release:

all:	compile

compile:
	/opt/scala/bin/scalac -classpath . -sourcepath . *.scala

test:
	/opt/scala/bin/scala -classpath . App ~/cg/lookat

test2:
	/opt/scala/bin/scala -classpath . App ~/cg/_cobbler

test3:
	/opt/scala/bin/scala -classpath . App ~/cg/func

clean:
	rm *.class

[edit] Making it work

Ideally, add a new-target to the makefile that points at a codebase that you have cloned locally, then run the build:

make compile new-target

[edit] Problems

  • Make sure you are running the latest Scala from upstream, even if it means using the tarball and putting it at /opt/scala.
  • Fedora 11 or later? It's suppose to work on those platforms.

[edit] Solutions

  • Adding debug and print commands: System.out.println and System.err.println.
    • For instance, in the code:
System.err.println("Processing " + commit_ttl + " commits, this may take a while...")
  • Some tips from 'lookatgit' original author:
    • It is likely hung somehow. The code is executing things via Runtime.getRuntime() ... a side effect of Scala using the JVM is it is bad at executing processes. There is a requirement to consume pending input or it will hang.