Git Dry Run?

Git Dry Run?

by Ken Task -
Number of replies: 12
Picture of Particularly helpful Moodlers

Let's say one has a Moodle 3.3.5+ Build: 20180322 installed.

Is there a way to see what code/files will change in a 3.3.5+ Build: 20180329
(that's the weekly release) via git without really pulling the trigger on an actual git pull ... like a git pull dry run?

Thanks, in advance, Ken


Average of ratings: -
In reply to Ken Task

Re: Git Dry Run?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

dit diff <a> <b>   shows you the difference between two commits

So... if your local branch is called master and your moodle remote is 'origin', something like...

git diff master origin/MOODLE_35_STABLE

...will show you all the code changes between your local version and the last commit on the 3.5 branch. There'll probably be a lot of stuff. 

If you just want to know the files that changed then add the switch --name-only.

Average of ratings: Useful (1)
In reply to Ken Task

Re: Git Dry Run?

by Ken Task -
Picture of Particularly helpful Moodlers

@Al @Howard ... thanks, guys!  That will give me something to play with! smile

Thankful, Ken


In reply to Ken Task

Re: Git Dry Run?

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

If you really want something to play with, because I know you aren't busy at all, big grin , I have a new version of a plugin that needs testing. wide eyes

Just kidding...Glad to return the favor as your answers have helped me too many times to count.

In reply to AL Rachels

Re: Git Dry Run?

by Ken Task -
Picture of Particularly helpful Moodlers

@Al ... I would if I could just find the time - unfortunately, involved in a project that is creating a bald spot (too much scratching)! :\

Always glad to hear I've been helpful. ;)

'spirit of sharing', Ken


In reply to Ken Task

Re: Git Dry Run?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If you really want a challenge... figure out the commits 'between' your branch and the remote branch wink

Sometimes that's more useful. 

In reply to Howard Miller

Re: Git Dry Run?

by Ken Task -
Picture of Particularly helpful Moodlers

@Howard ... was just thinking that commits is really the only way to get a dry run diff between git known versions ... but how does one find the commit of a version that git doesn't yet know about ...

Seeking the diff, for example, of a git installed and maintained 3.3.5 and not yet known 3.3.5+ ... that's only a weeks worth.

I can see on:

https://github.com/moodle/moodle/tree/MOODLE_33_STABLE

Latest commit 6a643e9 3 days ago - the weekly release 3.3.5+

But would like to figure out how to acquire that via command line.

Like this:

Kens-MacBook-Pro-2:moodle33 kentask$ git diff 6a643e9 c2abd2c --name-only
install/lang/sk/install.php
version.php

Better go get some sav for the bald spot! :\

'spirit of sharing', Ken


In reply to Ken Task

Re: Git Dry Run?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Ken - as I like to say, let's take a step or two back. 

What problem are you trying to solve here?

By "not yet known" do you just mean "stuff on a remote branch I don't have (yet)"? I can't think of a use-case where I've cared about that. Just pull the damn update big grin big grin

In reply to Howard Miller

Re: Git Dry Run?

by Ken Task -
Picture of Particularly helpful Moodlers

Yes, 'stuff on remote branch I don't have (yet)' ... exactly.   Sometimes, at the end of the life of a series/point release, about the only thing that is pulled is the version.php file and the environment files.   Since I don't know that, running the script I use to update which backs up the site just prior to the git pull takes up space/time, etc.

Even if 'the long list of fixes' could be found individually, I'd kinda like to be forewarned with each update if possible ... by forewarned I mean if I had a listing of file changes I have info for investigating.   Would turn on debugging anyway for hickups.

Now that's core ... most of the time, no issues ... however, could treat plugins the same way IF provider of plugin has a git repo.   The add on info would be useful, me thinks.

Granted most folks aren't that 'curious'! ;)

'spirit of sharing', Ken

In reply to Ken Task

Re: Git Dry Run?

by Aaron Hoffer -

If I  understand correctly, you are looking for "git fetch origin"

The command "fetch" will pull down changes from the repository "origin", but will not try to merge them into your currently checked-out branch.

In reply to Aaron Hoffer

Re: Git Dry Run?

by Ken Task -
Picture of Particularly helpful Moodlers

Thanks, Aaron!

Following your lead, did some more digging and found this little nugget:

https://stackoverflow.com/questions/10063407/git-log-output-log-file

git log --oneline --decorate > log.txt; cat log.txt

cat log.txt |more

6a643e96d6 (HEAD -> MOODLE_33_STABLE, origin/MOODLE_33_STABLE) weekly release 3.3.5+
0742adc1f8 Merge branch 'install_33_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_33_STABLE
c2abd2c0f0 Merge branch 'MDL-61770-33' of git://github.com/andrewnicols/moodle into MOODLE_33_STABLE
8256acd42e MDL-61770 iplookup: Check types rather than values
085f325851 Merge branch 'MDL-39060-33' of git://github.com/zig-moodle/moodle into MOODLE_33_STABLE
4d26291ddc MDL-51362 libraries: Remove deprecated admin tool unittest

Looks like everything I didn't want to know ... which is what I wanted to know! ;) [sick mind!]

Might be useful to others?

'spirit of sharing', Ken


In reply to Ken Task

Re: Git Dry Run?

by Ken Task -
Picture of Particularly helpful Moodlers

Follow up ... hickup!???

The first git pull rendered this:

Updating b87a580aa3..6a643e96d6
error: Your local changes to the following files would be overwritten by merge:

Then listed a bunch of files ending below:

    availability/condition/completion/lang/en/availability_completion.php
    availability/condition/completion/yui/build/moodle-availability_completion-form/moodle-availability_completion-form-debug.js
    availability/condition/completion/yui/build/moodle-availability_completion-form/moodle-availabilit
Aborting

Just a test directory ... no changes were made to any file ... just added a bash shell script for creating the text log file and that wasn't made executable ... source 'scriptname'.

Issuing a 'git reset --hard'

put it back on 'track' ... yes, pun intended! ;)

and then another git pull everything OK then

'spirit of sharing', Ken