fsprojects / ProjectScaffold

A prototypical .NET solution (file system layout and tooling), recommended for F# projects
http://fsprojects.github.io/ProjectScaffold
The Unlicense
515 stars 154 forks source link

Install should erase git history #276

Closed jackfoxy closed 6 years ago

jackfoxy commented 7 years ago

Description

Install (initial build) should erase git history

Repro steps

Last I checked, cloning and doing initial build for a new project retains the entire ProjectScaffold history.

Expected behavior

Leaving this open for discussion. Some alternatives to handle in initial install build:

1) squash this history 2) delete the history entirely (delete .git folder, git init)

Actual behavior

Your new project git history looks like a fork of ProjectScaffold

Known workarounds

Manually squash or delete history

Related information

n/a

jackfoxy commented 7 years ago

Personally, I favor the delete history route, but if others see value in squashing, that works too.

pblasucci commented 7 years ago

There's supposed to be a step in the init script that nukes any git history and, optionally, sets up a new origin. Perhaps it's not working correctly? Of course, if there's a different/better way to handle things, I'm all for it.

Paulmichael Blasucci

jackfoxy commented 7 years ago

My workflow is usually NOT to immediately set an upstream origin to GitHub, and I suspect this is a common workflow.

The code in init.fsx looks like it should properly handle this workflow, but apparently it does not. I have not traced the problem, and it will be some time before I can fix this, so for now I am just fully documenting what I found:

1) There is a documentation lacuna in the "Getting Started" section. (<== represents missing steps)

Project summary Project description Author's name for NuGet package Tags for NuGet package (separated by spaces)

        <== Github url (leave blank to use "https://github.com")
        <== Github raw url (leave blank to use "https://raw.githubusercontent.com")

GitHub username GitHub project name (if different than project name from above)

        <== Initialize git repo [Yn]
        <== Origin (url of git remote; blank to skip)

2) Following the workflow of either accepting the default or entering Y at "Initialize git repo [Yn]" and skipping the step "Origin (url of git remote; blank to skip)" results in a git project that still has the entire ProjectScaffold history present. I have not tested whether setting origin has this issue or not.

3) (unrelated) I confirmed and reported another issue with this workflow https://github.com/fsprojects/ProjectScaffold/issues/277

By visual inspection the code in init.fsx at line 250 (Git.Repository.init SOURCE_DIRECTORY false false) should execute...I don't know why it is not.

Once this is fixed, I cannot imagine why the prompt "Initialize git repo [Yn]" is desirable (I prefer minimalistic init scripts). What is the use case for retaining ProjectScaffold history in your project at all?

pblasucci commented 7 years ago

I agree almost entirely with you @jackfoxy... this is definitely a bug in the init.fsx and the documentation needs updating. However, I think the Initialize git repo [Yn]? is still needed. The idea being:

In either case, the previous git history should definitely be nuked. I'm not saying we absolutely have to have this functionality. But that's the behavior that was originally intend. Perhaps the prompt needs different wording?

jackfoxy commented 6 years ago

I'm not sure how this PR is supposed to work. I merged it into my fork, ran a test, selected Initialize git repo [Yn]? Y, and it did not wipe the git history. I don't think my init.fsx diverges from main in any important way.

Ah, I see. This probably fixes it if there is a remote. My workflow always starts with no remote. Gives me a path forward, thanks.

jackfoxy commented 6 years ago

For those of us who start out without a remote, the following one line change will wipe git history. I will leave this to others to decide if this is a good idea:

if isGitRepo () && hasScaffoldOrigin () then

if isGitRepo () then

I don't know of any justification to restricting this to only if a remote exists.

rmunn commented 6 years ago

There's also a problem if the URL doesn't end with .git, which I've just submitted a PR for. As for the question of whether the history should be cleared if there is no remote, I'm leaning towards not doing that. The main issue is that we don't want to accidentally delete someone's real history if the init.fsx script gets copied into a non-ProjectScaffold repo. Checking the remote URL is a good way to guard against that scenario, but if there's no remote, it's not guaranteed to be safe to delete the .git folder.