1
\$\begingroup\$

Background

Sometimes, people think you didn't work at your git project. But - you can prove yourself with git shortlog -n. Now, the problem is you are a programmer and programmers are lazy. So you want to write a program which shows the person who committed at most.

Rules

You may not do the following things:

  • use git shortlog with the argument -s

  • use any alias, which calls git on any way

You may assume the following:

  • git is installed on the system

  • You are in the working directory of the repository where to find out the person

  • The output of git shortlog -n will be piped in your program, but you may also call the command in your program, even though I can't see the advantage.

  • If there is a language-specific package or library for git, you may use it.

The output

Your program has to output the name of the person with the most commits in the repo.

This is a challenge, so the program with the least amount of bytes wins!

\$\endgroup\$
10
  • \$\begingroup\$ Language-specific rules are typically frowned upon. Did you Sandbox this? \$\endgroup\$ Jul 16, 2017 at 16:01
  • \$\begingroup\$ @musicman523 No, sorry, I forgot to. The rules are only are workaround for languages who can't directly call a command, but I'll change it. \$\endgroup\$
    – univalence
    Jul 16, 2017 at 16:03
  • 1
    \$\begingroup\$ Please specify what is wrong with the question if you downvoted. \$\endgroup\$
    – univalence
    Jul 16, 2017 at 16:37
  • \$\begingroup\$ Can we assume that the user has no ( in his name? \$\endgroup\$
    – ovs
    Jul 16, 2017 at 16:37
  • 1
    \$\begingroup\$ @Leo Here is an example output from Retina \$\endgroup\$
    – ovs
    Jul 16, 2017 at 17:01

8 Answers 8

3
\$\begingroup\$

Bash, 20 bytes

head -1|cut -d\( -f1

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Bash, 18 bytes

sed -n 1s/.\(.*//p

Try it online!

sed, 11 bytes

Run with -n (counted as +1 byte).

1s/ (.*//p

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ Personally I would just call this a sed answer, not a Bash answer \$\endgroup\$ Jul 16, 2017 at 20:24
3
\$\begingroup\$

Befunge-98, 10 bytes

~:'(-!#@_,

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Retina, 8 bytes

s` \(.*

Try it online! Example input is the output from shortlog -n from Retina.

\$\endgroup\$
2
\$\begingroup\$

Python 3, 29 bytes

print(input().split(' (')[0])

Try it online! Example input is the output from shortlog -n from Retina.

\$\endgroup\$
2
\$\begingroup\$

AWK, 9 bytes

NR<2,NF--

Try it online!

This one is just a test, consisting of two statements, without any associated code block. The first test NR<2 determines the truthy'ness of the test. So the default code block, which is effectively print $0, is only run for the first line of the input.

The secondary statement, NF-- just drop the last field in the input line.

\$\endgroup\$
1
\$\begingroup\$

05AB1E, 4 bytes

'(¡¬

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ Version without trailing space: #¨ðý \$\endgroup\$ Jul 16, 2017 at 17:50
0
\$\begingroup\$

Jelly, 4 bytes

ṣ”(Ḣ

Try it online!

My first Jelly answer!

How?

ṣ”(Ḣ - Main Link. Takes a string X on left
ṣ    - Split X on the occurrences of
 ”(  - Literal "("
   Ḣ - Head
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.