Skip to content

Conversation

@aitorvs
Copy link
Collaborator

@aitorvs aitorvs commented Aug 4, 2021

Task/Issue URL: https://app.asana.com/0/414730916066338/1200701185339027/f
Tech Design URL:
CC:

Description:
This PR adds a .githooks folder where all commit hooks we think should be shared across the devs should be placed, and adds the first hook which runs spotless on all modules for every commit to ensure our code styling is always correct.

Unfortunatelly GIT does not allow to directly check-in the hooks in the .git/hooks directory. Also anything in those folders are not cloned. The rational seems to be that a clone repository is a local copy, so sharing the hooks would go against that de-centralised approach.

However, it is possible to share a folder where we can place those hooks, ie. .githooks and then tell git where it needs to look for them. The downside is that we are adding a config step but that should be ok.

The setup for a newcomer to the repo would be:

  1. clone the repo
  2. cd the repo directory
  3. execute git config core.hooksPath .githooks

From that point forward, git will look into .githooks rather than .git/hooks

Steps to test this PR:

  1. checkout this branch
  2. run git config core.hooksPath .githooks
  3. Go to FeedActivity line 141
  4. Remove the space before the { in supportFragmentManager.transaction {
  5. run git commit -a -m test
  6. verify spotless runs and the commit is greated but it is empty ;)
  7. Go to AppUrl line 19
  8. Remove the space before the { in class AppUrl {
  9. run git commit -a -m test2
  10. verify spotless runs and the commit is greated but it is empty ;)

Internal references:

Software Engineering Expectations
Technical Design Template

@malmstein malmstein self-assigned this Aug 4, 2021
@marcosholgado
Copy link
Contributor

marcosholgado commented Aug 4, 2021

👋 I'm not sure this works for all the modules. Can we also test steps 3 and 4 in a different module? Like the di module to make sure it does also work there since that module doesn't apply spotless in its gradle file?

@aitorvs aitorvs force-pushed the lhf/aitor/spotless_everything branch from 10417d7 to a12bb6b Compare August 4, 2021 08:29
@aitorvs
Copy link
Collaborator Author

aitorvs commented Aug 4, 2021

👋 I'm not sure this works for all the modules. Can we also test steps 3 and 4 in a different module? Like the di module to make sure it does also work there since that module doesn't apply spotless in its gradle file?

arg, I had forgotten to modify the android-library.gradle to make sure all modules run spotless.
When commiting that change spotless ran in all modules fixing code styles in some files, as can be seen in this PR.

I will also another test step to the description

Copy link
Contributor

@malmstein malmstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as described, thanks @aitorvs and @marcosholgado!

@aitorvs aitorvs merged commit f7f2413 into develop Aug 4, 2021
@aitorvs aitorvs deleted the lhf/aitor/spotless_everything branch August 4, 2021 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants