Code Monkey home page Code Monkey logo

git-animate's Introduction

git-animate

Reads through a git repo and turns each commit into a series of vim keystrokes. The result is a pseudo-timelapse which almost looks like it's being typed out by a real person. Results vary depending on how frequent the commits were. It's also still only doing linewise diffs, so even a single byte change means the whole line is re-typed.

Only works on a single file. It is a good idea to rebase any merge commits so that the history reads as if it was written by a single author.

pip install -r requirements.txt

process.py reads the git history and outputs the patches as a list of tuples representing changes. If the repo contains multiple files, specify a filename to filter as an argument. E.g. ./process.py gbjs.htm > patches.txt Multiple filenames can be provided if the file was renamed.

playback.py reads the patches file and turns it into keystrokes. Run the script and then focus on a new terminal window. Hold esc to abort.

These scripts were used to produce this video.

git-animate's People

Contributors

mitxela avatar mp-pinheiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

git-animate's Issues

Trouble with upgraded libs (can't run it)

Hey there!

I'm not sure if you still look at this, but I'm really interested in using it for some devlog videos and I'd love a helping hand!

So I think the biggest problem is that the dependencies have changed over time, I'll try to lay down every problem I ran into trying to get this to run.

1) On the README file, this is said regarding dependencies:

pip install git whatthepatch keyboard

To which I'm immediately greeted with:

ERROR: Could not find a version that satisfies the requirement git (from versions: none)
ERROR: No matching distribution found for git

I assume the git package must be GitPython on PyPI, so that's what I installed.

2) After cloning the files into my git repo and updating the EMPTY_TREE_SHA, a couple things happen:

2.1) This line:

for diff in whatthepatch.parse_patch(patch)

fails with the following message:

TypeError: cannot use a string pattern on a bytes-like object

I assume this happens because this line:

patch = commits[0].diff(EMPTY_TREE_SHA, create_patch=True)[0].diff

was supposed to return a string. So I changed it to this:

patch = commits[0].diff(EMPTY_TREE_SHA,
                        create_patch=True)[0].diff.decode("utf-8")

Printing the variable patch gives me the expected diff string, so it looks correct, but I'm not sure.

2.2) Now the problem is with this line:

for (i, d, t) in diff.changes:

The error is a simple ValueError: too many values to unpack (expected 3), so I assumed the GitPython lib must've added something to the Changes object, which looks like it's the case:

[Change(old=1, new=None, line='[submodule "Class"]', hunk=1), Change(old=2, new=None, line='\tpath = Class', hunk=1), Change(old=3, new=None, line='\turl = https://github.com/preischadt/Class', hunk=1)]

So I just added a throwaway variable to the unpacking to get rid of that hunk property that looked like constant. Like this:

for (i, d, t, _) in diff.changes:
        print(d, i, t)

2.3) Then I applied the same changes to the code inside the commits loop:

patch = commits[i - 1].diff(c, create_patch=True)[0].diff.decode("utf-8")

    for diff in whatthepatch.parse_patch(patch):
        for (d, i, t, _) in diff.changes:
            if d == None or i == None:
                print(d, i, t)

And there we go, here's my output:

None 1 [submodule "Class"]
None 2  path = Class
None 3  url = https://github.com/preischadt/Class
Lucas Pinheiro Event Class implementation

It looks correct to me, but I'm not sure what it should look like, so that's what brings me here! Saving my output to a file and running playback.py results only in VIM opening up, putting in the two settings (set syntax=html and set timeoutlen=1000 ttimeoutlen=0), and then the script reads all lines, and just ends.

This is most likely the line causing the problem:

(d, i, t) = ast.literal_eval(line)

It seems never to be able to evaluate that expression.


So another thing I tried was tracking the releases of the GitPython and whatthepatch to try and get the ones close to December 2018, around the date where you uploaded your GameBoy emulator video using the script. I was able to install some older versions, and although that fixed the extra hunk property from the Changes class in GitPython, that was all.

After all that I decided it might be worth a shot reaching for some help here. Sorry for the gigantic wall of text, I don't want to be a nuisance, and I really loved what you did with this project in your video, so I totally understand if you don't have the time or don't want to help.

Thanks in advance!

Not working

I have followed your steps, It created the "pathches.txt"

But when I run in terminal:
"python playback.py patches.tx"

It just opens an empty VIM inside the same terminal and nothing happens.

patches.tx looks like so

image

It is not clear in your Readme whether the whole "replay" shall run in the VIM INSIDE the terminal or in the VIM application. In your video it looks like it's running in your VIM editor because it's all colored, but I am not sure.

Maybe a video on its usage would be helpful? Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.