Integrating git with the Wolfram Language
Integrating git with the Wolfram Language
What is git?
What is git?
Sorry, this is the 60-second-intro-that-probably-still-leaves-you-lost version if you haven’t been exposed to it before...
◇
Version control system
Version control system
◇
Decentralized
Decentralized
◇
Represents commits, directories, and files relationally in a directed acyclic graph
Represents commits, directories, and files relationally in a directed acyclic graph
◇
Repos contain an object store, where the objects being stored are:
Repos contain an object store, where the objects being stored are:
• Commits
• Commits
• Trees
• Trees
• Blobs
• Blobs
◇
Object store is indexed by hexadecimal hashes known as SHAs
Object store is indexed by hexadecimal hashes known as SHAs
What is git — a visualization
What is git — a visualization
SetDirectory[NotebookDirectory[]];Manipulate[GitGraph[GitOpen["repos/TalkRepo.git"],"GraphDetail"->selector],{selector,{"Commits","Trees","Blobs"}}]
Why access git from the Wolfram Language?
Why access git from the Wolfram Language?
◇
A natural extension of a symbolic language
A natural extension of a symbolic language
◇
Language support for tooling is a known good
Language support for tooling is a known good
◇
Git is the leader in version control
Git is the leader in version control
◇
Want to be able to support merging of notebooks
Want to be able to support merging of notebooks
◇
Turned out to be an invaluable internal tool
Turned out to be an invaluable internal tool
A basic introduction
A basic introduction
Repo creation/acquisition
Repo creation/acquisition
r=GitOpen["C:\\wolfram\\git\\GitLink"]
rclone=GitClone["repos/TalkRepo.git","../TalkRepo"]
rnew=GitInit["../NewRepo"]
A basic introduction
A basic introduction
What can you do with a repo?
What can you do with a repo?
Get its properties:
GitProperties[rnew]
ShallowQFalse,EmptyQTrue,UnbornHeadQTrue,BareQFalse,GitDirectoryC:\wolfram\git\NewRepo\.git\,WorkingDirectoryC:\wolfram\git\NewRepo\,DetachedHeadQFalse,Namespace$Failed,StateNone,Conflicts{},Remotes,LocalBranches{},RemoteBranches{},Tags{}
See its status:
GitStatus[rnew]
New{},Modified{},Deleted{},TypeChange{},IndexNew{},IndexModified{},IndexDeleted{},IndexTypeChange{}
Add changes and commit changes:
Put[Sqrt[2],FileNameJoin[{rnew["WorkingDirectory"],"radical.wl"}]];
GitAdd[rnew,"radical.wl"]
{radical.wl}
c=GitCommit[rnew,"Added a radical"]
Get information on commits:
GitProperties[c]
TypeCommit,Parents{},Tree,AuthorNameJohn Fultz,Emailjfultz@wolfram.com,TimeStamp,CommitterNameJohn Fultz,Emailjfultz@wolfram.com,TimeStamp,SHA6d37eb7b86316c7cb9c2eedf73d83af85b1c3ab9,MessageAdded a radical,Repo
Release resources:
GitClose[rnew]
Some more advanced concepts...
Some more advanced concepts...
Accessing arbitrary revisions
Accessing arbitrary revisions
ToGitObject[rclone,"master"]
GitRange[rclone,"master"]
,,
GitRange[rclone,"master",Not["master~2"]]
,
GitGraph[%,"GraphDetail"->"Commits"]
Some more advanced concepts...
Some more advanced concepts...
Accessing trees and blobs
Accessing trees and blobs
So what can we do with it?
So what can we do with it?
Let’s do something practical...get some line counts
Let’s do something practical...get some line counts
So what can we do with it?
So what can we do with it?
Let’s do something practical...get some line counts
Let’s do something practical...get some line counts
Line counts
Line counts
This is easy!
This is easy!
Line counts
Line counts
Foiled by some messy data...what to do?
Foiled by some messy data...what to do?
Line counts
Line counts
Final solution...clean up the outliers
Final solution...clean up the outliers
More fun with GitLink
More fun with GitLink
A branch browser (how many languages can build this in 13 lines of code?)
A branch browser (how many languages can build this in 13 lines of code?)
[He’s showing off now...]
[He’s showing off now...]
A branch browser with differencing
A branch browser with differencing
Code
Code
Demo
Demo
But it solved real problems for us
But it solved real problems for us
◇
Post-processing repos migrated from cvs
Post-processing repos migrated from cvs
◇
Random git scriptability needs (e.g., let’s find all named and fully merged feature branches and clean them up)
Random git scriptability needs (e.g., let’s find all named and fully merged feature branches and clean them up)
◇
Implementing a multi-repo management tool
Implementing a multi-repo management tool
◇
Doing automated merge deployments of development branches (how we avoid having to have a “develop” branch slowing down our releases)
Doing automated merge deployments of development branches (how we avoid having to have a “develop” branch slowing down our releases)
We built a thing...
We built a thing...
Yummy, yummy dog food. 50+ developers use this every day at Wolfram.
Yummy, yummy dog food. 50+ developers use this every day at Wolfram.
And...
And...
3-way notebook merging...
3-way notebook merging...
When’s it shipping?
When’s it shipping?
A large amount is already done
A large amount is already done
We need to get some more coverage of git functionality
We need to get some more coverage of git functionality
Some details may change before we ship. I’ll update this talk to reflect any changes.
Some details may change before we ship. I’ll update this talk to reflect any changes.
Update? But where would we find it?
Update? But where would we find it?
Github, of course!
Github, of course!
This is repo #1. More to follow.
This is repo #1. More to follow.