1 Any wiki with a form of web-editing enabled will have to deal with
2 spam. (See the [[plugins/blogspam]] plugin for one defensive tool you
7 * you are using ikiwiki to manage the website for a [[examples/softwaresite]]
8 * you allow web-based commits, to let people correct documentation, or report
10 * the documentation is stored in the same revision control repository as your
13 It is undesirable to have your software's VCS history tainted by spam and spam
14 clean-up commits. Here is one approach you can use to prevent this. This
15 example is for the [[git]] version control system, but the principles should
18 ## Isolate web commits to a specific branch
20 Create a separate branch to contain web-originated edits (named `doc` in this
25 Adjust your setup file accordingly:
27 gitmaster_branch => 'doc',
29 ## merging good web commits into the master branch
31 You will want to periodically merge legitimate web-based commits back into
32 your master branch. Ensure that there is no spam in the documentation
33 branch. If there is, see 'erase spam from the commit history', below, first.
35 Once you are confident it's clean:
37 # ensure you are on the master branch
47 In the short term, just revert the spammy commit.
49 If the spammy commit was the top-most:
53 This will clean the spam out of the files, but it will leave both the spam
54 commit and the revert commit in the history.
56 ### erase spam from the commit history
58 Git allows you to rewrite your commit history. We will take advantage of this
59 to eradicate spam from the history of the doc branch.
61 This is a useful tool, but it is considered bad practise to rewrite the
62 history of public repositories. If your software's repository is public, you
63 should make it clear that the history of the `doc` branch in your repository
66 Once you have been spammed, use `git rebase` to remove the spam commits from
67 the history. Assuming that your `doc` branch was split off from a branch
70 # ensure you are on the doc branch
74 $ git rebase --interactive master
76 In your editor session, you will see a series of lines for each commit made to
77 the `doc` branch since it was branched from `master` (or since the last merge
78 back into `master`). Delete the lines corresponding to spammy commits, then
79 save and exit your editor.
81 Caveat: if there are no commits you want to keep (i.e. all the commits since
82 the last merge into master are either spam or spam reverts) then `git rebase`
83 will abort. Therefore, this approach only works if you have at least one
84 non-spam commit to the documentation since the last merge into `master`. For
85 this reason, it's best to wait until you have at least one
86 commit you want merged back into the main history before doing a rebase,
87 and until then, tackle spam with reverts.