git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/3] bring some tests to newer style.
@ 2018-09-21 23:58 Stefan Beller
  2018-09-21 23:58 ` [PATCH 1/3] t7001: reformat " Stefan Beller
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Stefan Beller @ 2018-09-21 23:58 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller

The old formatting style is a real hindrance of getting people up to speed
contributing as they use existing code as an example and follow that style.
So let's get rid of the old style and reformat it in our current style.

This was reported off list by Derrick and Jeff as both of them followed
outdated formatting style for their first patches only to have a long
discussion on the mailing list on style.

The tests changed are not modified in origin/master..origin/pu,
and they were changed using a hacky script:
--8<--
#!/usr/bin/python
import sys
def applyformat(fname):
	with open(fname, 'r') as f:
		lines = f.readlines()
		state = "lookingforstart"
		outlines = []
		for line in lines:
			if state == "lookingforstart":
				if line == "test_expect_success \\\n":
					print "AHA!"
					state = "firstlinefound"
				else:
					outlines += [line]
			elif state == "firstlinefound":
				l = line.strip()
				must_strip = False
				if l.endswith("\\"):
					l = l[:-1]
					must_strip=True
				if l.endswith("'"):
					l = l[:-1].strip()
				if l.startswith("'"):
					line = "test_expect_success " + l + " '\n"
					outlines += [line]
					state = "re-indent-until-done"
				else:
					print "what?"
					exit(1)
			elif state == "re-indent-until-done":
				l = line.strip()
				if must_strip:
					if l.startswith("'"):
						l = l[1:]
						must_strip = False
					else:
						print "what 1?"
						exit(1)
				if l.endswith("'"):
					l = l[:-1]
					state = "lookingforstart"

				if len(l):
					line = "	" + l + "\n"
					outlines += [line]
				elif state == "lookingforstart":
					# skip an empty line before test is done
					pass
				else:
					outlines += ["\n"]

				if state == "lookingforstart":
					outlines += ["'\n"]
			else:
				print "what?"
				exit(1)
	with open(fname, 'w') as f:
		f.write(''.join(outlines))

for n in sys.argv[1:]:
	print n
	applyformat(n)
--8<--

Thanks,
Stefan

Stefan Beller (3):
  t7001: reformat to newer style
  t7004: reformat style
  t0030: reformat style

 t/t0030-stripspace.sh | 525 ++++++++++++++++++++----------------------
 t/t7001-mv.sh         | 268 ++++++++++-----------
 t/t7004-tag.sh        | 149 +++++-------
 3 files changed, 444 insertions(+), 498 deletions(-)

-- 
2.19.0.444.g18242da7ef-goog


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-09-25 20:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-21 23:58 [PATCH 0/3] bring some tests to newer style Stefan Beller
2018-09-21 23:58 ` [PATCH 1/3] t7001: reformat " Stefan Beller
2018-09-24 13:31   ` Derrick Stolee
2018-09-24 16:09     ` Junio C Hamano
2018-09-24 18:51     ` Stefan Beller
2018-09-25 20:36       ` Junio C Hamano
2018-09-21 23:58 ` [PATCH 2/3] t7004: reformat style Stefan Beller
2018-09-21 23:58 ` [PATCH 3/3] t0030: " Stefan Beller

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).