Using git for feedback from proof readers - r

I am currently writing a text with R bookdown and asked two friends to read my text and give comments, corrections and general feedback. My source files for the text are stored on GitHub and I would like my collaborators to make changes in the files (one for each chapter) with the help of git. However, none of us are really experts on git. This makes it hard to figure out what a suitable workflow is.
For now, we decided that each one of them creates himself a branch so that he does not directly push into the master branch. After I have read their changes I would like to decide what I merge into the master branch and what not. So far, it looks like each change needs to be in a separate commit because I am not able to merge single lines from a specific commit (not sure if that is at all possible). However, this seems like a lot of annoying and unnecessary commits to create. So, I guess I am looking for a way to avoid that and/or general pointers towards a good workflow for such kind of projects.

A useful command will be git cherry-pick, it allows you to select specific commits from a branch.
A general good practice is that commits should be self contained (if applied alone they make sense) and they target a specific feature (in the use case mentioned, that could be a paragraph or a section or a chapter).
In the end, if you would like to apply only specific changes of a commit, that would have to happen manually, someone has to decide which parts to apply and which not. A commit can be edited using git rebase -i <branch name> before being merged. This question might also be useful.

I finally found what worked for me in here. Basically, on my master branch I had to use
git merge --no-commit --no-ff branch-to-merge
This will merge all changes into my master branch but does not immediatly commit the changes so that they can still be staged/unstaged. Then, I can decide what line change to include by staging the line changes I want to keep and discard all other line changes. Finally, I commit all staged line changes et voilà, that's what I wanted to get.
Sidenote: I am using gitkraken and as a beginner with git I enjoy using the GUI but the merge part with the options "no-commit" and "no-fast-forwarding" had to be done via the git console (at least I could not find a way to to that using the GUI). Choosing which lines to stage and which to discard is then an easy task via the GUI.

Related

Is there a way to make R code only able to be run and not edited? Essentially read-only?

I am in the midst of writing some scripts to perform data analysis on large excel sheets faster than by hand. However, my company has a strict quality review system where the program used needs to be validated and secure (i.e. no one can edit it, there is proof of what code was run, etc.). So essentially I would like my code to be able to be ran by my coworkers without them being able to edit the script. I was also interested in inserting prompts that they can fill in (e.g. "Which column would you like to analyze?")
Is all of this possible? I have read a few things online about file permissions but I know that these can easily be changed by the user. I also read about obfuscators but am entirely unfamiliar with their use.
One thought I have is to use Rmarkdown as a method of displaying which lines were run for which results. However, I believe that document could be edited as well? This would also leave the issue of the script itself being able to be edited.

How can I create a copy of a notebok with all (or most) code cells emptied?

I want to create Jupyter notebooks for teaching, which shall be delivered in two versions:
A full “textbook” with explanations in markdown cells and example code in code cells.
As above, but with most code cells being empty such that the students have to type all the code themselves.
Obviously, I do not want to do this manually in Jupyter, so I need a way to automatically clear those code cells (exceptions are rare and can be marked somehow).
Given that notebooks are stored as sources of Python objects, I could write a simple script to directly modify those.
However, this feels like I am re-inventing the wheel instead f using some existing, dedicated method – which what I am seeking in this question.
I briefly considered using NBGrader. However, while I am quite confident that this could solve my problem, it seems overkill for this purpose and require extra effort to make things work.
Have you checked out Chris Holdgraf's nbclean?

Convenient diff of patch files in Gerrit

My team using Gerrit for reviewing of changes and sometimes we have to push .patch for some files. Sometimes these .patches could reach over ~1000 lines (which obviously not good for reviewing). It is very inconvenient to review it as diff between patches itself. It would be better(in some cases) to review it as diff of origin file and origin file with applied patch(not diff between .patches). Even if original file isn't under version control, committer could attach it with patch set, right?
Unfortunately, after lasting googling i didn't find anything...
Is there any way to show diff between two patch files (not patch sets) in such approach or similar?
I think the best you can do is to find a three-way merge tool to compare
the original source;
the source with the old patch; and
the source with the new patch.
To use such a tool, I think you'd need to use the command lines the Gerrit interface provides to fetch the changes locally, then apply the patches, then use the merge tool for the review.
I don't think you'll find a way to get a "three-way merge" view of the code in the Gerrit UI itself.

SVN in ASP.NET with Ankh basics for day-to-day usage

My team now has an SVN + Ankh setup in ASP.NET with trunk, branches, and tags. We switch branches and work on code, but many times there will be inexplicable conflicts in files after simple changes. Why is this? I suspect we simply don't understand enough of how this works. Are there any do's and don'ts, or how should we be approaching our daily changes and commits, without causing conflicts? Is there a basic pecking order of operations to perform to achieve SVN zen? Are we updating before committing or something? Any help is greatly appreciated.
Always update before commit. If you really work with branches don't use switch or only if you really undstand the switch command and how it works otherwise checkout a branch into a fresh working copy in other words create a new one.
Always branch, merge on the solution element, make sure you're fully up to date before merging (ankhsvn will warn about this), also make sure you have no modified files before merging.
Read up on svnbook for when to use normal merging and when to use reintegrate.
Finally, if a conflict does occur, make sure you have a good 3way merge tool to solve the conflict. AnkhSVN recognizes a lot of them automatically, but I really like source gear diffmerge

Want to revert back 3 revisions, how?

Let's say I have a user's object, I deleted a property and all things in the web project that used this property (admin pages that updated the property, data layer etc etc).
Now I was told that we need that property, looking at Subversions log it seems the correct code is 3 revisions back.
How can I go back, then somehow get any updates that may have occurred by other devleopers also?
Get the revision number from log for the correct code. Right-click the file you want to rollback. Select Tortoise SVN -> Update to Revision. In dialog fill number of revision you what to update file to, click OK and you are done!
EDIT:- to perform action on command line use svn merge. for more information type following in command line:
svn --help merge ENTER
Here is link to SVN book describing the operation.
You can also have a look at this question, which is also about same issue.
You'll need to know which files you want, and update all to "HEAD" and then those specific files to "HEAD - 3" revision number. Then you'll need to commit those specific files back.
There maybe a better option that I'm not aware of.
If you committed the whole change, and only that change in one go, you can back out that change to your working copy. You could then commit that if it works.
Log Messages > right-click the offending revision > Revert changes from this revision
I've only tried it for a small number of files, I imagine there could be serious conflict headaches.
Theoretically, you can reverse merge. I tried once and subversion absolutely failed to do this--corrupted my working copy or just flat out crashed every single time.
Practically, you might have to update to the old version, save off copies of the files affected, update to latest, manually reverse merge the changes.
It would be a lot more practical (though unsophisticated) if you can just update 3 revs back, recommit it, and have anyone who made changes since recommit them.
Use the log dialog.
Select the revision you want to revert. Right-click on that revision, choose "revert changes from this revision".

Resources